shukdevdatta123 commited on
Commit
6020e53
Β·
verified Β·
1 Parent(s): 8d69e71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -15,10 +15,10 @@ def generate_speech(reference_audio_path, text):
15
  text: the string to synthesize
16
  returns: path to a 24 kHz WAV file with your cloned voice
17
  """
18
- # Load the reference clip (Tortoise auto-resamples to 22 050 Hz)
19
- ref_waveform = load_audio(reference_audio_path)
20
 
21
- # Generate speech using 'fast' preset
22
  output_tensor = tts.tts_with_preset(
23
  text,
24
  voice_samples=[ref_waveform],
@@ -33,18 +33,18 @@ def generate_speech(reference_audio_path, text):
33
 
34
  # 3) Build the Gradio interface
35
  with gr.Blocks(title="Tortoise Voice Cloning TTS") as app:
36
- gr.Markdown("## Voice Cloning with Tortoise TTS")
37
  gr.Markdown(
38
  "Upload a ~10 sec WAV clip (22 050 Hz), enter English text, "
39
  "and hear it spoken back in **your** voice!"
40
  )
41
 
42
  with gr.Row():
43
- voice_sample = gr.Audio(type="filepath", label="Upload Reference Voice (22 050 Hz WAV)")
44
- text_input = gr.Textbox(label="Text to Synthesize", placeholder="e.g., Hello, world!")
45
 
46
- generate_btn = gr.Button("Generate Speech")
47
- output_audio = gr.Audio(label="Cloned Speech Output (24 kHz)", interactive=False)
48
 
49
  generate_btn.click(
50
  fn=generate_speech,
@@ -53,4 +53,4 @@ with gr.Blocks(title="Tortoise Voice Cloning TTS") as app:
53
  )
54
 
55
  if __name__ == "__main__":
56
- app.launch()
 
15
  text: the string to synthesize
16
  returns: path to a 24 kHz WAV file with your cloned voice
17
  """
18
+ # βœ… FIXED: Provide sampling_rate as a required positional argument
19
+ ref_waveform = load_audio(reference_audio_path, 22050)
20
 
21
+ # Generate speech using 'fast' preset (alternatives: ultra_fast, standard, high_quality)
22
  output_tensor = tts.tts_with_preset(
23
  text,
24
  voice_samples=[ref_waveform],
 
33
 
34
  # 3) Build the Gradio interface
35
  with gr.Blocks(title="Tortoise Voice Cloning TTS") as app:
36
+ gr.Markdown("## πŸ—£οΈ Voice Cloning with Tortoise TTS")
37
  gr.Markdown(
38
  "Upload a ~10 sec WAV clip (22 050 Hz), enter English text, "
39
  "and hear it spoken back in **your** voice!"
40
  )
41
 
42
  with gr.Row():
43
+ voice_sample = gr.Audio(type="filepath", label="πŸŽ™οΈ Upload Reference Voice (22 050 Hz WAV)")
44
+ text_input = gr.Textbox(label="πŸ’¬ Text to Synthesize", placeholder="e.g., Hello, world!")
45
 
46
+ generate_btn = gr.Button("πŸ”Š Generate Speech")
47
+ output_audio = gr.Audio(label="πŸ“’ Cloned Speech Output (24 kHz)", interactive=False)
48
 
49
  generate_btn.click(
50
  fn=generate_speech,
 
53
  )
54
 
55
  if __name__ == "__main__":
56
+ app.launch()