drewThomasson commited on
Commit
a553ade
β€’
1 Parent(s): 5dc8e6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -93,7 +93,7 @@ def create_speaker_with_transcription(audio_file):
93
  audio_file (file): Uploaded reference audio file.
94
 
95
  Returns:
96
- dict or None: Speaker configuration or None if failed.
97
  """
98
  logger.info("Received Voice Cloning request with audio file.")
99
 
@@ -110,7 +110,7 @@ def create_speaker_with_transcription(audio_file):
110
  if not transcript.strip():
111
  logger.error("Transcription resulted in empty text.")
112
  os.remove(temp_audio_path)
113
- return None
114
 
115
  # Create speaker using the transcribed text
116
  speaker = interface.create_speaker(temp_audio_path, transcript)
@@ -123,7 +123,7 @@ def create_speaker_with_transcription(audio_file):
123
  return speaker
124
  except Exception as e:
125
  logger.error(f"Error during speaker creation: {e}")
126
- return None
127
 
128
  def generate_tts_cloned(text, temperature, repetition_penalty, max_length, speaker):
129
  """
@@ -143,7 +143,7 @@ def generate_tts_cloned(text, temperature, repetition_penalty, max_length, speak
143
  logger.info(f"Parameters - Text: {text}, Temperature: {temperature}, Repetition Penalty: {repetition_penalty}, Max Length: {max_length}, Speaker Provided: {speaker is not None}")
144
 
145
  try:
146
- if speaker is None:
147
  logger.error("Speaker configuration is missing.")
148
  return None
149
 
@@ -230,12 +230,12 @@ with gr.Blocks() as demo:
230
  with gr.Row():
231
  reference_audio = gr.Audio(
232
  label="πŸ”Š Reference Audio",
233
- type="filepath", # Use 'filepath' to receive the path to the uploaded file
234
  )
235
 
236
  create_speaker_button = gr.Button("🎀 Create Speaker")
237
 
238
- speaker_info = gr.JSON(label="πŸ—‚οΈ Speaker Configuration", interactive=False)
239
 
240
  with gr.Row():
241
  generate_cloned_speech = gr.Textbox(
 
93
  audio_file (file): Uploaded reference audio file.
94
 
95
  Returns:
96
+ dict: Speaker configuration or empty dict if failed.
97
  """
98
  logger.info("Received Voice Cloning request with audio file.")
99
 
 
110
  if not transcript.strip():
111
  logger.error("Transcription resulted in empty text.")
112
  os.remove(temp_audio_path)
113
+ return {}
114
 
115
  # Create speaker using the transcribed text
116
  speaker = interface.create_speaker(temp_audio_path, transcript)
 
123
  return speaker
124
  except Exception as e:
125
  logger.error(f"Error during speaker creation: {e}")
126
+ return {}
127
 
128
  def generate_tts_cloned(text, temperature, repetition_penalty, max_length, speaker):
129
  """
 
143
  logger.info(f"Parameters - Text: {text}, Temperature: {temperature}, Repetition Penalty: {repetition_penalty}, Max Length: {max_length}, Speaker Provided: {speaker is not None}")
144
 
145
  try:
146
+ if not speaker:
147
  logger.error("Speaker configuration is missing.")
148
  return None
149
 
 
230
  with gr.Row():
231
  reference_audio = gr.Audio(
232
  label="πŸ”Š Reference Audio",
233
+ type="filepath" # Receive the path to the uploaded file
234
  )
235
 
236
  create_speaker_button = gr.Button("🎀 Create Speaker")
237
 
238
+ speaker_info = gr.JSON(label="πŸ—‚οΈ Speaker Configuration") # Removed interactive=False
239
 
240
  with gr.Row():
241
  generate_cloned_speech = gr.Textbox(