Skip to content

Commit

Permalink
Make sure aiy.audio.say uses the aiy.i18n's language. (google#113)
Browse files Browse the repository at this point in the history
Tested:
  Changed $HOME/.config/voice-recognizer.ini to use en-GB.
  Ran src/main.py --cloud_speech
  Verified the TTS sound has a British accent.
  • Loading branch information
enetor authored Jul 27, 2017
1 parent 3c7dddc commit c735c69
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/aiy/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ def play_audio(audio_data):
player.play_bytes(audio_data, sample_width=AUDIO_SAMPLE_SIZE, sample_rate=AUDIO_SAMPLE_RATE_HZ)


def say(words, lang='en-US'):
"""Says the given words in the given language with Google TTS engine."""
def say(words, lang=None):
"""Says the given words in the given language with Google TTS engine.
If lang is specified, e.g. "en-US', it will be used to say the given words.
Otherwise, the language from aiy.i18n will be used.
"""
if not lang:
lang = aiy.i18n.get_language_code()
aiy._drivers._tts.say(aiy.audio.get_player(), words, lang=lang)


Expand Down

0 comments on commit c735c69

Please sign in to comment.