Tonic commited on
Commit
540a7bb
β€’
1 Parent(s): fe2ecf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -10,7 +10,6 @@ import numpy as np
10
  import torch.nn.functional as F
11
  from whisperspeech.pipeline import Pipeline
12
  from whisperspeech.languages import LANGUAGES
13
- from whisperspeech.pipeline import Pipeline
14
  from whisperspeech.utils import resampler
15
 
16
  title = """# πŸ™‹πŸ»β€β™‚οΈ Welcome to🌟CollaboraπŸŒ¬οΈπŸ’¬πŸ“WhisperSpeech
@@ -37,7 +36,7 @@ def parse_multilingual_text(input_text):
37
  segments = re.findall(pattern, input_text)
38
  return [(lang, text.strip()) for lang, text in segments if lang in LANGUAGES.keys()]
39
 
40
- @spaces.GPU
41
  def generate_segment_audio(text, lang, speaker_audio, pipe):
42
  if not isinstance(text, str):
43
  text = text.decode("utf-8") if isinstance(text, bytes) else str(text)
@@ -61,6 +60,9 @@ def whisper_speech_demo(multilingual_text, speaker_audio):
61
  return None, "No valid language segments found. Please use the format: <lang> text"
62
 
63
  pipe = Pipeline()
 
 
 
64
  speaker_url = speaker_audio if speaker_audio is not None else None
65
  audio_segments = []
66
 
 
10
  import torch.nn.functional as F
11
  from whisperspeech.pipeline import Pipeline
12
  from whisperspeech.languages import LANGUAGES
 
13
  from whisperspeech.utils import resampler
14
 
15
  title = """# πŸ™‹πŸ»β€β™‚οΈ Welcome to🌟CollaboraπŸŒ¬οΈπŸ’¬πŸ“WhisperSpeech
 
36
  segments = re.findall(pattern, input_text)
37
  return [(lang, text.strip()) for lang, text in segments if lang in LANGUAGES.keys()]
38
 
39
+ @spaces.GPU(enable_queue=True)
40
  def generate_segment_audio(text, lang, speaker_audio, pipe):
41
  if not isinstance(text, str):
42
  text = text.decode("utf-8") if isinstance(text, bytes) else str(text)
 
60
  return None, "No valid language segments found. Please use the format: <lang> text"
61
 
62
  pipe = Pipeline()
63
+ if not hasattr(pipe, 's2a'):
64
+ return None, "Pipeline initialization failed. s2a model not loaded."
65
+
66
  speaker_url = speaker_audio if speaker_audio is not None else None
67
  audio_segments = []
68