Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text to Speech enableTimePointing not working in Python

Using texttospeech_v1beta1 to get ssml_mark but getting

"TypeError: synthesize_speech() got an unexpected keyword argument 'enableTimePointing'" error.

    from google.cloud import texttospeech_v1beta1

    client = texttospeech_v1beta1.TextToSpeechClient()synthesis_input = texttospeech_v1beta1.SynthesisInput(ssml=text)
    voice = texttospeech_v1beta1.VoiceSelectionParams(language_code='tr-TR',name='tr-TR-Wavenet-E')
    audio_config = texttospeech_v1beta1.AudioConfig(
    audio_encoding=texttospeech_v1beta1.AudioEncoding.MP3)
    response = client.synthesize_speech(input=synthesis_input, voice=voice, audio_config=audio_config, enableTimePointing = 'SSML_MARK')
    print(response.timepoints)
like image 514
Mustafa Akcacakir Avatar asked Feb 03 '26 10:02

Mustafa Akcacakir


1 Answers

You need to create a SynthesizeSpeechRequest Object instead of passing the arguments individually into client.synthesize_speech

So,

request = texttospeech_v1beta1.SynthesizeSpeechRequest(
    input=synthesis_input,
    voice=voice,
    audio_config=audio_config,
    enable_time_pointing=[texttospeech_v1beta1.SynthesizeSpeechRequest.TimepointType.SSML_MARK]

response = client.synthesize_speech(request)
like image 138
holla_a_m_ego Avatar answered Feb 08 '26 14:02

holla_a_m_ego



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!