Kurian07 commited on
Commit
37224c9
·
verified ·
1 Parent(s): de20c52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -9,13 +9,14 @@ st.title("PDF to Speech with gTTS")
9
 
10
  # Description
11
  st.write("""
12
- This app lets you upload a PDF, extracts the text, and converts it into a human-like voice using Google Text-to-Speech (gTTS).
13
  You can adjust the **speed** and **language** for a personalized experience.
14
  """)
15
 
16
  # Sidebar options for customization
17
  st.sidebar.header("Customize Voice")
18
  speed = st.sidebar.slider("Speech Speed (rate)", min_value=100, max_value=300, value=150, step=10) # 100 to 300 words per minute
 
19
  language = st.sidebar.selectbox("Language", ["English", "French", "Spanish", "German"], index=0) # Select language
20
 
21
  # File upload
@@ -49,7 +50,7 @@ if uploaded_file is not None:
49
  text = text[:max_length]
50
 
51
  # Generate speech using gTTS
52
- tts = gTTS(text=text, lang=language_mapping[language], slow=False)
53
 
54
  # Save audio to a temporary file
55
  with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as temp_file:
 
9
 
10
  # Description
11
  st.write("""
12
+ This app lets you upload a PDF, extracts the text, and converts it into a human-like voice using Google Text-to-Speech (gTTS).
13
  You can adjust the **speed** and **language** for a personalized experience.
14
  """)
15
 
16
  # Sidebar options for customization
17
  st.sidebar.header("Customize Voice")
18
  speed = st.sidebar.slider("Speech Speed (rate)", min_value=100, max_value=300, value=150, step=10) # 100 to 300 words per minute
19
+ slow = st.sidebar.checkbox("Slow Down the Speech", value=False) # Slow down speech
20
  language = st.sidebar.selectbox("Language", ["English", "French", "Spanish", "German"], index=0) # Select language
21
 
22
  # File upload
 
50
  text = text[:max_length]
51
 
52
  # Generate speech using gTTS
53
+ tts = gTTS(text=text, lang=language_mapping[language], slow=slow)
54
 
55
  # Save audio to a temporary file
56
  with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as temp_file: