liuyang commited on
Commit
aa22724
ยท
1 Parent(s): 533afcb

global pipeline

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -29,6 +29,16 @@ except subprocess.CalledProcessError:
29
  print("Warning: Could not install flash-attn, falling back to default attention")
30
  '''
31
 
 
 
 
 
 
 
 
 
 
 
32
  def comprehensive_flash_attention_verification():
33
  """Comprehensive verification of flash attention setup"""
34
  print("๐Ÿ” Running Flash Attention Verification...")
@@ -147,7 +157,7 @@ def comprehensive_flash_attention_verification():
147
 
148
  class WhisperTranscriber:
149
  def __init__(self):
150
- self.pipe = None
151
  self.diarization_model = None
152
 
153
  #@spaces.GPU
@@ -415,8 +425,8 @@ class WhisperTranscriber:
415
 
416
  finally:
417
  # Clean up temporary file
418
- if os.path.exists(wav_path):
419
- os.unlink(wav_path)
420
 
421
  except Exception as e:
422
  import traceback
@@ -560,5 +570,4 @@ with demo:
560
  """)
561
 
562
  if __name__ == "__main__":
563
- transcriber.setup_models()
564
  demo.launch(debug=True)
 
29
  print("Warning: Could not install flash-attn, falling back to default attention")
30
  '''
31
 
32
+ # Create global pipeline (similar to working HuggingFace example)
33
+ pipe = pipeline(
34
+ "automatic-speech-recognition",
35
+ model="openai/whisper-large-v3-turbo",
36
+ torch_dtype=torch.float16,
37
+ device="cuda:0",
38
+ model_kwargs={"attn_implementation": "flash_attention_2"},
39
+ return_timestamps=True,
40
+ )
41
+
42
  def comprehensive_flash_attention_verification():
43
  """Comprehensive verification of flash attention setup"""
44
  print("๐Ÿ” Running Flash Attention Verification...")
 
157
 
158
  class WhisperTranscriber:
159
  def __init__(self):
160
+ self.pipe = pipe # Use global pipeline
161
  self.diarization_model = None
162
 
163
  #@spaces.GPU
 
425
 
426
  finally:
427
  # Clean up temporary file
428
+ if os.path.exists(audio_file):
429
+ os.unlink(audio_file)
430
 
431
  except Exception as e:
432
  import traceback
 
570
  """)
571
 
572
  if __name__ == "__main__":
 
573
  demo.launch(debug=True)