capradeepgujaran commited on
Commit
ae0a74a
1 Parent(s): ce9d36e

Update openai_tts_tool.py

Browse files
Files changed (1) hide show
  1. openai_tts_tool.py +5 -4
openai_tts_tool.py CHANGED
@@ -1,5 +1,4 @@
1
  from openai import OpenAI
2
- import tempfile
3
  import os
4
 
5
  def generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_speed, language, output_option, summary_length, additional_prompt):
@@ -23,11 +22,13 @@ def generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_s
23
  # Generate audio if requested
24
  audio_file = None
25
  if output_option in ["audio", "both"]:
 
26
  speech_response = client.audio.speech.create(
27
- model="tts-1", # or "tts-1-hd" for higher quality
28
  voice=voice_type,
29
  input=input_text,
30
- speed=float(voice_speed)
 
31
  )
32
 
33
  # Create temp directory if it doesn't exist
@@ -54,4 +55,4 @@ def generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_s
54
  except Exception as e:
55
  return None, f"Error: {str(e)}"
56
 
57
- return None, None
 
1
  from openai import OpenAI
 
2
  import os
3
 
4
  def generate_audio_and_text(api_key, input_text, model_name, voice_type, voice_speed, language, output_option, summary_length, additional_prompt):
 
22
  # Generate audio if requested
23
  audio_file = None
24
  if output_option in ["audio", "both"]:
25
+ # Ensure language is passed correctly for TTS generation
26
  speech_response = client.audio.speech.create(
27
+ model="tts-1", # Adjust model if necessary for other languages
28
  voice=voice_type,
29
  input=input_text,
30
+ speed=float(voice_speed),
31
+ language=language # Pass the selected language here
32
  )
33
 
34
  # Create temp directory if it doesn't exist
 
55
  except Exception as e:
56
  return None, f"Error: {str(e)}"
57
 
58
+ return None, None