elevenlabs / elevenlabs-python

The official Python API for ElevenLabs Text to Speech.
https://elevenlabs.io/docs/api-reference/getting-started
MIT License
2.2k stars 255 forks source link

Output Format Issue with Realtime Streaming #333

Closed Kaister300 closed 3 months ago

Kaister300 commented 3 months ago

In version 1.5.0, there was an update to the realtime_tts.py file (see Merge #321) which added output_format in the method signature. However, in client.py the Elevenlabs generate method does not pass the output_format value. The only change needed should be to add output_format somewhere when calling convert_realtime. Could a quick fix be put in for this?

# src/elevenlabs/client.py
class ElevenLabs(...):
    def generate(...):
         ...
         if stream:
              if isinstance(text, str):
                  return self.text_to_speech.convert_as_stream(
                      voice_id=voice_id,
                      voice_settings=voice_settings,
                      optimize_streaming_latency=optimize_streaming_latency,
                      output_format=output_format,
                      text=text,
                      request_options=request_options,
                      pronunciation_dictionary_locators=pronunciation_dictionary_locators,
                      model_id=model_id
                  )
              elif isinstance(text, Iterator):
                  return self.text_to_speech.convert_realtime(  # type: ignore
                      voice_id=voice_id,
                      voice_settings=voice_settings,
                      output_format=output_format,  # Added line
                      text=text,
                      request_options=request_options,
                      model_id=model_id
                  )
              else: 
                  raise ApiError(body="")
         ...
dsinghvi commented 3 months ago

@Kaister300 thanks for the great callout, we'll make a change here