harmoni_microphone.microphone_service

Module Contents

Classes

MicrophoneService

Reads from a microphone and publishes audio data.

Functions

main()

Set names, collect params, and give service to server

class harmoni_microphone.microphone_service.MicrophoneService(name, param)

Bases: harmoni_common_lib.service_manager.HarmoniServiceManager

Reads from a microphone and publishes audio data.

As a sensor service, the microphone is responsible for reading the audio data from a physical microphone and publishing it so that it can be recorded or transcribed by a detector.

The microphone has many parameters which are set in the configuration.yaml

The public functions exposed by the microphone include start(), stop(), and pause()

service_id

Setup the microphone

start()

Start the microphone stream and publish audio

stop()

Stop the service and close the stream

pause()

Set the service to success to stop publishing

setup_microphone()

Setup the microphone

_open_stream()

Open the microphone audio stream with configured params

_close_stream()

When possibly, the pyaudio stream object should be closed

_read_stream_and_publish()

Continously publish audio data from the microphone

While state is START publish audio

_get_device_index()

Find the input audio devices configured in ~/.asoundrc. If the device is not found, pyaudio will use your machine default device

start_recording_data()

Init the subscriber to microphone/default for recording audio.

The callback in the subscriber will save the audio to a file specified in the configuration yaml.

_record_audio_data_callback(data)

Callback function to write data

harmoni_microphone.microphone_service.main()

Set names, collect params, and give service to server