Hi there. I've been exploring the various voices offered by Google Text-To-Speech, specifically various speeds for various voices. Here's the sample code.
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
def speak(text, voice_name = "en-US-Journey-O", speaking_rate = 0.8):
if text.strip():
voice = texttospeech.VoiceSelectionParams(
language_code="en-US",
ssml_gender=texttospeech.SsmlVoiceGender.FEMALE,
name=voice_name,
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3,
speaking_rate=speaking_rate
)
synthesis_input = texttospeech.SynthesisInput(text=text.strip())
return client.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
else:
return None
sample = """The total number of characters in the input string are counted for billing purposes, including spaces."""
for voice in ["en-US-Journey-O", "en-US-Standard-C"]:
for speed in [0.6, 0.8, 1]:
result = speak(sample, voice, speed)
if result:
with open(f"./{voice}_{speed}.mp3", "wb") as f:
f.write(result.audio_content)
Upon downloading the files I noticed that the `speaking_rate` param isn't affecting the speed and length of audio at all for only Journey Voice.
The question is: is speaking_rate supported by Journey voices? If not can this piece of info be included in the docs in case I missed it?
Having the same problem here...
Did you solve this issue?
I had the same issue and couldn't fix it.
Found an alternative to use the Studio Voice and then the speaking rate can be changed!
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |