Tonic commited on
Commit
25a42f3
·
verified ·
1 Parent(s): 18de3a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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
- text = text.decode("utf-8") if isinstance(text, bytes) else str(text)
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']