Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -66,7 +66,18 @@ class TTS_Interface:
|
|
66 |
def read(self, prompt, language, accent, speaker):
|
67 |
language = language.split()[0]
|
68 |
accent = accent.split()[0]
|
69 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
if language == "English":
|
71 |
prompt = "Your input was too long. Please try either a shorter text or split it into several parts."
|
72 |
elif language == "German":
|
@@ -91,17 +102,9 @@ class TTS_Interface:
|
|
91 |
prompt = "O seu contributo foi demasiado longo. Por favor, tente um texto mais curto ou divida-o em várias partes."
|
92 |
elif language == 'Italian':
|
93 |
prompt = "Il tuo input era troppo lungo. Per favore, prova un testo più corto o dividilo in più parti."
|
|
|
94 |
|
95 |
-
|
96 |
-
self.model.set_phonemizer_language(self.language_id_lookup[language])
|
97 |
-
self.current_language = language
|
98 |
-
if self.current_accent != accent:
|
99 |
-
self.model.set_accent_language(self.language_id_lookup[accent])
|
100 |
-
self.current_accent = accent
|
101 |
-
if self.current_speaker != speaker:
|
102 |
-
self.model.set_utterance_embedding(self.speaker_path_lookup[speaker])
|
103 |
-
self.current_speaker = speaker
|
104 |
-
wav = self.model(prompt)
|
105 |
return 48000, float2pcm(wav.cpu().numpy())
|
106 |
|
107 |
|
|
|
66 |
def read(self, prompt, language, accent, speaker):
|
67 |
language = language.split()[0]
|
68 |
accent = accent.split()[0]
|
69 |
+
if self.current_language != language:
|
70 |
+
self.model.set_phonemizer_language(self.language_id_lookup[language])
|
71 |
+
self.current_language = language
|
72 |
+
if self.current_accent != accent:
|
73 |
+
self.model.set_accent_language(self.language_id_lookup[accent])
|
74 |
+
self.current_accent = accent
|
75 |
+
if self.current_speaker != speaker:
|
76 |
+
self.model.set_utterance_embedding(self.speaker_path_lookup[speaker])
|
77 |
+
self.current_speaker = speaker
|
78 |
+
|
79 |
+
phones = self.model.text2phone.get_phone_string(prompt)
|
80 |
+
if len(phones) > 1800:
|
81 |
if language == "English":
|
82 |
prompt = "Your input was too long. Please try either a shorter text or split it into several parts."
|
83 |
elif language == "German":
|
|
|
102 |
prompt = "O seu contributo foi demasiado longo. Por favor, tente um texto mais curto ou divida-o em várias partes."
|
103 |
elif language == 'Italian':
|
104 |
prompt = "Il tuo input era troppo lungo. Per favore, prova un testo più corto o dividilo in più parti."
|
105 |
+
phones = self.model.text2phone.get_phone_string(prompt)
|
106 |
|
107 |
+
wav = self.model(phones)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
return 48000, float2pcm(wav.cpu().numpy())
|
109 |
|
110 |
|