Spaces:
Running
Running
c_2
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import time
|
|
|
|
|
4 |
import tempfile
|
5 |
import subprocess
|
6 |
import requests
|
@@ -11,9 +13,31 @@ import torch
|
|
11 |
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
|
12 |
import yt_dlp
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# Set up logging
|
15 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# Check for CUDA availability
|
18 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
19 |
logging.info(f"Using device: {device}")
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import time
|
4 |
+
import sys
|
5 |
+
import io
|
6 |
import tempfile
|
7 |
import subprocess
|
8 |
import requests
|
|
|
13 |
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
|
14 |
import yt_dlp
|
15 |
|
16 |
+
class LogCapture(io.StringIO):
|
17 |
+
def __init__(self, callback):
|
18 |
+
super().__init__()
|
19 |
+
self.callback = callback
|
20 |
+
|
21 |
+
def write(self, s):
|
22 |
+
super().write(s)
|
23 |
+
self.callback(s)
|
24 |
+
|
25 |
# Set up logging
|
26 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
27 |
|
28 |
+
# Clone and install faster-whisper from GitHub
|
29 |
+
try:
|
30 |
+
subprocess.run(["git", "clone", "https://github.com/SYSTRAN/faster-whisper.git"], check=True)
|
31 |
+
subprocess.run(["pip", "install", "-e", "./faster-whisper"], check=True)
|
32 |
+
except subprocess.CalledProcessError as e:
|
33 |
+
logging.error(f"Error during faster-whisper installation: {e}")
|
34 |
+
sys.exit(1)
|
35 |
+
|
36 |
+
sys.path.append("./faster-whisper")
|
37 |
+
|
38 |
+
from faster_whisper import WhisperModel
|
39 |
+
from faster_whisper.transcribe import BatchedInferencePipeline
|
40 |
+
|
41 |
# Check for CUDA availability
|
42 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
43 |
logging.info(f"Using device: {device}")
|