alexa / avs-device-sdk

An SDK for commercial device makers to integrate Alexa directly into connected products.
https://developer.amazon.com/alexa/alexa-voice-service
Apache License 2.0
1.26k stars 604 forks source link

Question regarding input option for AVS device #1233

Closed lenhattu closed 5 years ago

lenhattu commented 5 years ago

I would like to input text commands to AVS instead of using voice (for the purpose of automated testing). I know that AVS only has voice input option. Is there a proper way to modify AVS sdk for my specific use case?

As far as I know, the speech recognition task is done on the cloud so the cloud only accepts audio input from AVS device. I'm thinking about first using text-to-speech to make audio files from my text commands (e.g., "Alexa, read news from Fox News"). Then, when running SampleApp, I want to cut down the voice input from microphone and read input from my audio files instead. I tried looking at the UserInputManager in SampleApp but I couldn't figure out where it takes the user's voice command. Could you please point me to the right place?

I appreciate your help!

scotthea-amazon commented 5 years ago

Hello lenhattu,

I am not sure what framework you are using to drive your testing, but if you are using DefaultClient, you should be able to pass audio in through notifyOfTapToTalk(), notifyOfTapToTalk() or notifyOfHoldToTalkStart().

If you are using SampleApp, and want to provide a more continuous source of audio, you could provide your own implementation of MicrophoneInterface in SampleApp (here) that writes audio to the local variable sharedDataStream.

Best regards, -SWH

lenhattu commented 5 years ago

Hello lenhattu,

I am not sure what framework you are using to drive your testing, but if you are using DefaultClient, you should be able to pass audio in through notifyOfTapToTalk(), notifyOfTapToTalk() or notifyOfHoldToTalkStart().

If you are using SampleApp, and want to provide a more continuous source of audio, you could provide your own implementation of MicrophoneInterface in SampleApp (here) that writes audio to the local variable sharedDataStream.

Best regards, -SWH

Hi SWH,

Thank you for your reply.

I just want to read audio input from file instead of microphone.

By passing audio in through notifyOfTapToTalk(), do you mean modifying "capabilityAgents::aip::AudioProvider tapToTalkAudioProvider" or something? I'm not sure how to pass my audio file into this one. Can you please give me more details?

If I use SampleApp and write my audio file into this location: sharedDataStream, do I need to disable the voice input from microphone somewhere?

scotthea-amazon commented 5 years ago

Hello lenhattu,

Regarding notifyOfTapToTalk(): Yes, I mean by providing your own value for tapToTalkAudioProvider. To do this, you will need to initialize that structure including reading the bytes from your file and writing them to the AudioInputStream member 'stream'.

Regarding writing data to sharedDataStream: By replacing the initialization of micWrapper with your own implementation of MicrophoneInterface SampleApp will no longer be reading from the microphone.

Best regards, -SWH

camel113 commented 5 years ago

@lenhattu did you figure out how to send text input instead of audio input?

womw commented 5 years ago

@lenhattu I am closing this issue due to inactivity. If you still have an issue feel free to reopen or create a new issue.