Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -40,11 +40,16 @@ def parse_multilingual_text(input_text):
|
|
40 |
@spaces.GPU
|
41 |
def generate_segment_audio(text, lang, speaker_url, pipe):
|
42 |
|
|
|
43 |
if not isinstance(text, str):
|
|
|
|
|
|
|
|
|
44 |
print("Speaker Audio Type:", type(speaker_audio))
|
45 |
with open(speaker_audio, 'rb') as file:
|
46 |
speaker_audio = file.read()
|
47 |
-
|
48 |
audio_data = pipe.generate(text, speaker_audio, lang)
|
49 |
resample_audio = resampler(newsr=24000)
|
50 |
audio_data_resampled = next(resample_audio([{'sample_rate': 24000, 'samples': audio_data.cpu()}]))['samples_24k']
|
|
|
40 |
@spaces.GPU
|
41 |
def generate_segment_audio(text, lang, speaker_url, pipe):
|
42 |
|
43 |
+
# Ensure text is a string
|
44 |
if not isinstance(text, str):
|
45 |
+
text = text.decode("utf-8") if isinstance(text, bytes) else str(text)
|
46 |
+
|
47 |
+
# Check and process speaker_audio if it is a string (path to file)
|
48 |
+
if isinstance(speaker_audio, str):
|
49 |
print("Speaker Audio Type:", type(speaker_audio))
|
50 |
with open(speaker_audio, 'rb') as file:
|
51 |
speaker_audio = file.read()
|
52 |
+
|
53 |
audio_data = pipe.generate(text, speaker_audio, lang)
|
54 |
resample_audio = resampler(newsr=24000)
|
55 |
audio_data_resampled = next(resample_audio([{'sample_rate': 24000, 'samples': audio_data.cpu()}]))['samples_24k']
|