cnph001 commited on
Commit
5f7c847
·
verified ·
1 Parent(s): 54191b7

Updated for multiple voices

Browse files

Default = male, other voices 1F:US_Emma, 2F:US_Jenny, 3F:HK_Jan, 1M:US_Guy, 2M:AU_William, 1C: Childvoice

Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -13,15 +13,36 @@ async def get_voices():
13
 
14
  # Text-to-speech function for a single paragraph
15
  async def paragraph_to_speech(text, voice, rate, pitch):
16
- voice1 = "en-AU-WilliamNeural - en-AU (Male)"
17
- voice2 = "en-HK-YanNeural - en-HK (Female)"
 
 
 
 
 
18
  if not text.strip():
19
  return None
20
- if text.startswith("FF"):
21
  text2 = text[2:] # Remove the first two characters ("FF")
22
- voice_short_name =voice2.split(" - ")[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  else:
24
- voice_short_name = voice1.split(" - ")[0]
 
25
  text2=text
26
  rate_str = f"{rate:+d}%"
27
  pitch_str = f"{pitch:+d}Hz"
@@ -76,7 +97,7 @@ async def create_demo():
76
  voices = await get_voices()
77
 
78
  description = """
79
- Experience the power of Voicecloning.be for text-to-speech conversion.
80
  Enter your text, select a voice, and adjust the speech rate and pitch.
81
  The application will process your text paragraph by paragraph (separated by two blank lines).
82
  """
 
13
 
14
  # Text-to-speech function for a single paragraph
15
  async def paragraph_to_speech(text, voice, rate, pitch):
16
+ voice1 ="en-US-AndrewNeural - en-US (Male)" #good for reading
17
+ voice1F ="en-US-EmmaNeural - en-US" (Female)
18
+ voice2 = "en-US-GuyNeural (Male)"
19
+ voice2F = "en-US-JennyNeural (Female)"
20
+ voice3 = "en-AU-WilliamNeural - en-AU (Male)"
21
+ voice3F = "en-HK-YanNeural - en-HK (Female)"
22
+ voice4 = "en-GB-MaisieNeural - en-GB (Female)" #Child
23
  if not text.strip():
24
  return None
25
+ if text.startswith("1F"):
26
  text2 = text[2:] # Remove the first two characters ("FF")
27
+ voice_short_name =voice1F.split(" - ")[0]
28
+ elif text.startswith("2F"):
29
+ text2 = text[2:] # Remove the first two characters ("FF")
30
+ voice_short_name =voice2F.split(" - ")[0]
31
+ elif text.startswith("3F"):
32
+ text2 = text[2:] # Remove the first two characters ("FF")
33
+ voice_short_name =voice3F.split(" - ")[0]
34
+ elif text.startswith("1M"):
35
+ text2 = text[2:] # Remove the first two characters ("FF")
36
+ voice_short_name =voice2.split(" - ")[0]
37
+ elif text.startswith("2M"):
38
+ text2 = text[2:] # Remove the first two characters ("FF")
39
+ voice_short_name =voice3.split(" - ")[0]
40
+ elif text.startswith("1C"):
41
+ text2 = text[2:] # Remove the first two characters ("FF")
42
+ voice_short_name =voice4.split(" - ")[0]
43
  else:
44
+ # Use selected voice, or fallback to default
45
+ voice_short_name = (voice or default_voice).split(" - ")[0]
46
  text2=text
47
  rate_str = f"{rate:+d}%"
48
  pitch_str = f"{pitch:+d}Hz"
 
97
  voices = await get_voices()
98
 
99
  description = """
100
+ Default = male, other voices 1F:US_Emma, 2F:US_Jenny, 3F:HK_Jan, 1M:US_Guy, 2M:AU_William, 1C: Childvoice
101
  Enter your text, select a voice, and adjust the speech rate and pitch.
102
  The application will process your text paragraph by paragraph (separated by two blank lines).
103
  """