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 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(self)

Start the microphone stream and publish audio

stop(self)

Stop the service and close the stream

pause(self)

Set the service to success to stop publishing

setup_microphone(self)

Setup the microphone

_open_stream(self)

Open the microphone audio stream with configured params

_close_stream(self)

When possibly, the pyaudio stream object should be closed

_read_stream_and_publish(self)

Continously publish audio data from the microphone

While state is START publish audio

_get_device_index(self)

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

start_recording_data(self)

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(self, data)

Callback function to write data

microphone_service.main()

Set names, collect params, and give service to server