Hammad112 commited on
Commit
eee2253
·
verified ·
1 Parent(s): b8320e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -15,16 +15,28 @@ interface = outetts.InterfaceHF(model_version="0.2", cfg=model_config)
15
  st.title("OuteTTS Speech Synthesis")
16
  st.write("Enter text below to generate speech.")
17
 
 
 
 
 
 
 
 
 
 
 
 
18
  text_input = st.text_area("Text to convert to speech:", "Hello, this is an AI-generated voice.")
19
 
20
  if st.button("Generate Speech"):
21
  with st.spinner("Generating audio..."):
22
- # Generate speech
23
  output = interface.generate(
24
  text=text_input,
25
  temperature=0.1,
26
  repetition_penalty=1.1,
27
- max_length=4096
 
28
  )
29
 
30
  # Save the synthesized speech to a file
 
15
  st.title("OuteTTS Speech Synthesis")
16
  st.write("Enter text below to generate speech.")
17
 
18
+ # Sidebar for reference voice
19
+ st.sidebar.title("Voice Cloning")
20
+ reference_audio = st.sidebar.file_uploader("Upload a reference audio (wav)", type=["wav"])
21
+
22
+ if reference_audio:
23
+ ref_audio_path = "reference.wav"
24
+ with open(ref_audio_path, "wb") as f:
25
+ f.write(reference_audio.read())
26
+ else:
27
+ ref_audio_path = None
28
+
29
  text_input = st.text_area("Text to convert to speech:", "Hello, this is an AI-generated voice.")
30
 
31
  if st.button("Generate Speech"):
32
  with st.spinner("Generating audio..."):
33
+ # Generate speech with reference audio
34
  output = interface.generate(
35
  text=text_input,
36
  temperature=0.1,
37
  repetition_penalty=1.1,
38
+ max_length=4096,
39
+ speaker_wav=ref_audio_path if ref_audio_path else None
40
  )
41
 
42
  # Save the synthesized speech to a file