We a building a chatbot app for Google Home using Api.ai (Dialogflow now) which has both male and female historical figures. We are using Actions on google. Google lets you default to a male or female voice when deploying the app. Is there a way to switch between male to female voice dynamically, for example, using code in webhook?
Is there a way to have change female to male voice during the conversation in DialogFlow (Api.ai)
Asked Answered
Maybe. Although SSML supports a <voice>
tag, the documentation for Actions does not list it as supported. However, as you noted, there appears to be some support. The gender
and variant
attributes seem to work, at least for en-US. The languages
attribute doesn't seem to be. So something like this might work:
<speech>
<voice gender="male" variant="1">male</voice>
<voice gender="male" variant="2">male</voice>
<voice gender="female" variant="1">female</voice>
<voice gender="female" variant="2">female</voice>
</speech>
However what is documented as working is to adjust the pitch of the default voice (whichever one you pick) using the <prosody>
SSML tag. Here is an example you can use to see how it sounds if you vary the pitch:
<speech>
test
<prosody pitch="-1st">test</prosody>
<prosody pitch="-2st">test</prosody>
<prosody pitch="-3st">test</prosody>
<prosody pitch="-4st">test</prosody>
<prosody pitch="-5st">test</prosody>
<prosody pitch="-6st">test</prosody>
<prosody pitch="-7st">test</prosody>
<prosody pitch="-8st">test</prosody>
<prosody pitch="-9st">test</prosody>
<prosody pitch="+1st">test</prosody>
<prosody pitch="+2st">test</prosody>
<prosody pitch="+3st">test</prosody>
<prosody pitch="+4st">test</prosody>
<prosody pitch="+5st">test</prosody>
<prosody pitch="+6st">test</prosody>
<prosody pitch="+7st">test</prosody>
<prosody pitch="+8st">test</prosody>
<prosody pitch="+9st">test</prosody>
</speech>
You can also combine the two tags.
Thanks. I experimented and it seems though not published by Google, the message like: <speak><voice gender="female"> Say this in a female voice </voice></speak> this works - at least in the simulator . I will try your suggestion to make my voices distinct as I have 3 male and 2 female characters and it would be nice to have distinct voices for each of them –
Howe
Interesting! I didn't even try, since it wasn't documented to work. I've updated the answer. If the answer has been helpful, accepting and/or upvoting it would be appreciated. –
Jodhpurs
© 2022 - 2024 — McMap. All rights reserved.