Update app.py
Browse filesAdd Old man voice
1O = Old man
1C = Child
app.py
CHANGED
@@ -21,6 +21,7 @@ async def paragraph_to_speech(text, voice, rate, pitch):
|
|
21 |
voice1 = "en-AU-WilliamNeural - en-AU (Male)"
|
22 |
voice3F = "en-HK-YanNeural - en-HK (Female)"
|
23 |
voice4 = "en-GB-MaisieNeural - en-GB (Female)" #Child
|
|
|
24 |
if not text.strip():
|
25 |
return None
|
26 |
if text.startswith("1F"):
|
@@ -43,7 +44,12 @@ async def paragraph_to_speech(text, voice, rate, pitch):
|
|
43 |
voice_short_name =voice3.split(" - ")[0]
|
44 |
elif text.startswith("1C"):
|
45 |
text2 = text[2:] # Remove the first two characters ("FF")
|
46 |
-
voice_short_name =voice4.split(" - ")[0]
|
|
|
|
|
|
|
|
|
|
|
47 |
else:
|
48 |
# Use selected voice, or fallback to default
|
49 |
voice_short_name = (voice or default_voice).split(" - ")[0]
|
@@ -102,7 +108,7 @@ async def create_demo():
|
|
102 |
voices = await get_voices()
|
103 |
default_voice = "en-US-AndrewNeural - en-US (Male)" # 👈 Pick one of the available voices
|
104 |
description = """
|
105 |
-
Default = male, other voices 1F:US_Emma, 2F:US_Jenny, 3F:HK_Yan, 1M:AU_Will, 2M:IT_Guiseppe,3M:US_Brian, 1C: Childvoice
|
106 |
Enter your text, select a voice, and adjust the speech rate and pitch.
|
107 |
The application will process your text paragraph by paragraph (separated by two blank lines).
|
108 |
"""
|
@@ -113,7 +119,7 @@ async def create_demo():
|
|
113 |
gr.Textbox(label="Input Text", lines=5, placeholder="Separate paragraphs with two blank lines."),
|
114 |
gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=default_voice),
|
115 |
gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
|
116 |
-
gr.Slider(minimum=-
|
117 |
],
|
118 |
outputs=[
|
119 |
gr.Audio(label="Generated Audio", type="filepath"),
|
|
|
21 |
voice1 = "en-AU-WilliamNeural - en-AU (Male)"
|
22 |
voice3F = "en-HK-YanNeural - en-HK (Female)"
|
23 |
voice4 = "en-GB-MaisieNeural - en-GB (Female)" #Child
|
24 |
+
voice5 = "en-GB-RyanNeural - en-GB (Male)" #Old Man
|
25 |
if not text.strip():
|
26 |
return None
|
27 |
if text.startswith("1F"):
|
|
|
44 |
voice_short_name =voice3.split(" - ")[0]
|
45 |
elif text.startswith("1C"):
|
46 |
text2 = text[2:] # Remove the first two characters ("FF")
|
47 |
+
voice_short_name =voice4.split(" - ")[0]
|
48 |
+
elif text.startswith("1O"):
|
49 |
+
text2 = text[2:] # Remove the first two characters ("FF")
|
50 |
+
voice_short_name =voice5.split(" - ")[0]
|
51 |
+
pitch = -30
|
52 |
+
rate = -20
|
53 |
else:
|
54 |
# Use selected voice, or fallback to default
|
55 |
voice_short_name = (voice or default_voice).split(" - ")[0]
|
|
|
108 |
voices = await get_voices()
|
109 |
default_voice = "en-US-AndrewNeural - en-US (Male)" # 👈 Pick one of the available voices
|
110 |
description = """
|
111 |
+
Default = male, other voices 1F:US_Emma, 2F:US_Jenny, 3F:HK_Yan, 1M:AU_Will, 2M:IT_Guiseppe,3M:US_Brian, 1C: Childvoice, 1O = OldMan
|
112 |
Enter your text, select a voice, and adjust the speech rate and pitch.
|
113 |
The application will process your text paragraph by paragraph (separated by two blank lines).
|
114 |
"""
|
|
|
119 |
gr.Textbox(label="Input Text", lines=5, placeholder="Separate paragraphs with two blank lines."),
|
120 |
gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=default_voice),
|
121 |
gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
|
122 |
+
gr.Slider(minimum=-50, maximum=50, value=0, label="Pitch Adjustment (Hz)", step=1)
|
123 |
],
|
124 |
outputs=[
|
125 |
gr.Audio(label="Generated Audio", type="filepath"),
|