Godota commited on
Commit
25c5af9
·
1 Parent(s): 1a1c378
Files changed (2) hide show
  1. app.py +13 -14
  2. requirements.txt +9 -1
app.py CHANGED
@@ -2,20 +2,6 @@ import logging
2
  # Отключаем спам от httpx
3
  logging.getLogger("httpx").setLevel(logging.WARNING)
4
 
5
- # First, install flash-attention
6
- import subprocess
7
- import os
8
- subprocess.run("pip install -q moviepy", shell=True)
9
- subprocess.run("pip install -q imageio-ffmpeg", shell=True)
10
- # Install flash-attention with specific environment variable
11
- subprocess.run(
12
- "pip install flash-attn --no-build-isolation",
13
- env={"FLASH_ATTENTION_SKIP_CUDA_BUILD": "TRUE"},
14
- shell=True,
15
- )
16
-
17
- from moviepy.editor import VideoFileClip
18
- import tempfile
19
  import gradio as gr
20
  from transformers import pipeline
21
  import torch
@@ -26,6 +12,19 @@ from speechbrain.inference import EncoderClassifier
26
  import torchaudio
27
  import numpy as np
28
  from sklearn.cluster import AgglomerativeClustering
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  # Initialize Whisper with flash attention
31
  pipe = pipeline(
 
2
  # Отключаем спам от httpx
3
  logging.getLogger("httpx").setLevel(logging.WARNING)
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  import gradio as gr
6
  from transformers import pipeline
7
  import torch
 
12
  import torchaudio
13
  import numpy as np
14
  from sklearn.cluster import AgglomerativeClustering
15
+ import tempfile
16
+ import os
17
+ import subprocess
18
+ from moviepy.editor import VideoFileClip
19
+
20
+ # Initialize Whisper with flash attention
21
+ pipe = pipeline(
22
+ "automatic-speech-recognition",
23
+ model="openai/whisper-large-v3-turbo",
24
+ torch_dtype=torch.float16,
25
+ device="cuda:0",
26
+ model_kwargs={"attn_implementation": "flash_attention_2"},
27
+ )
28
 
29
  # Initialize Whisper with flash attention
30
  pipe = pipeline(
requirements.txt CHANGED
@@ -1,4 +1,12 @@
1
  transformers[torch]
2
  speechbrain
3
  scikit-learn
4
- moviepy
 
 
 
 
 
 
 
 
 
1
  transformers[torch]
2
  speechbrain
3
  scikit-learn
4
+ moviepy
5
+ imageio-ffmpeg
6
+ gradio
7
+ numpy
8
+ torchaudio
9
+ flash-attn
10
+ ffmpeg-python
11
+ --extra-index-url https://download.pytorch.org/whl/cu118
12
+ torch