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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -1,21 +1,15 @@
1
  import streamlit as st
2
- import torch
3
  import outetts
4
  from scipy.io.wavfile import write
5
 
6
  # Initialize model configuration
7
  model_config = outetts.HFModelConfig_v1(
8
  model_path="OuteAI/OuteTTS-0.2-500M",
9
- language="en"
10
  )
11
 
12
- # Load the model
13
- model = outetts.load_model(model_config)
14
-
15
- def generate_speech(text):
16
- with torch.no_grad():
17
- audio, sample_rate = model.infer(text)
18
- return audio, sample_rate
19
 
20
  # Streamlit UI
21
  st.title("OuteTTS Speech Synthesis")
@@ -25,9 +19,18 @@ text_input = st.text_area("Text to convert to speech:", "Hello, this is an AI-ge
25
 
26
  if st.button("Generate Speech"):
27
  with st.spinner("Generating audio..."):
28
- audio, sample_rate = generate_speech(text_input)
 
 
 
 
 
 
 
 
29
  output_path = "output.wav"
30
- write(output_path, sample_rate, audio)
31
-
 
32
  st.audio(output_path, format="audio/wav")
33
  st.success("Speech generated successfully!")
 
1
  import streamlit as st
 
2
  import outetts
3
  from scipy.io.wavfile import write
4
 
5
  # Initialize model configuration
6
  model_config = outetts.HFModelConfig_v1(
7
  model_path="OuteAI/OuteTTS-0.2-500M",
8
+ language="en" # Supported languages: en, zh, ja, ko
9
  )
10
 
11
+ # Initialize the interface
12
+ interface = outetts.InterfaceHF(model_version="0.2", cfg=model_config)
 
 
 
 
 
13
 
14
  # Streamlit UI
15
  st.title("OuteTTS Speech Synthesis")
 
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
31
  output_path = "output.wav"
32
+ output.save(output_path)
33
+
34
+ # Play the audio in the Streamlit app
35
  st.audio(output_path, format="audio/wav")
36
  st.success("Speech generated successfully!")