Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
docs(samples): add voice selection (#184)
Browse files Browse the repository at this point in the history
* docs(samples): add voice selection

* lint fix

* Update samples/snippets/detect_intent_stream.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

* Update samples/snippets/detect_intent_stream.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
  • Loading branch information
galz10 and busunkim96 committed Oct 14, 2021
1 parent 527b679 commit 778b86f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion samples/snippets/detect_intent_stream.py
Expand Up @@ -73,10 +73,23 @@ def detect_intent_stream(agent, session_id, audio_file_path, language_code):
def request_generator():
audio_input = session.AudioInput(config=input_audio_config)
query_input = session.QueryInput(audio=audio_input, language_code=language_code)
voice_selection = audio_config.VoiceSelectionParams()
synthesize_speech_config = audio_config.SynthesizeSpeechConfig()
output_audio_config = audio_config.OutputAudioConfig()

# Sets the voice name and gender
voice_selection.name = "en-GB-Standard-A"
voice_selection.ssml_gender = audio_config.SsmlVoiceGender.SSML_VOICE_GENDER_FEMALE

synthesize_speech_config.voice = voice_selection

# Sets the audio encoding
output_audio_config.audio_encoding = audio_config.OutputAudioEncoding.OUTPUT_AUDIO_ENCODING_UNSPECIFIED
output_audio_config.synthesize_speech_config = synthesize_speech_config

# The first request contains the configuration.
yield session.StreamingDetectIntentRequest(
session=session_path, query_input=query_input
session=session_path, query_input=query_input, output_audio_config=output_audio_config
)

# Here we are reading small chunks of audio data from a local
Expand Down

0 comments on commit 778b86f

Please sign in to comment.