Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -38,9 +38,9 @@ def convert_to_wav(audio_file):
|
|
38 |
# Initialize device for torch
|
39 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
40 |
|
41 |
-
# Load Whisper model and
|
42 |
whisper_processor = WhisperProcessor.from_pretrained("NbAiLab/nb-whisper-large")
|
43 |
-
whisper_model =
|
44 |
|
45 |
def transcribe_audio(audio_file):
|
46 |
if audio_file.endswith(".m4a"):
|
@@ -62,7 +62,6 @@ def transcribe_audio(audio_file):
|
|
62 |
result = f"Time taken: {output_time:.2f} seconds\nNumber of words: {len(text.split())}"
|
63 |
|
64 |
return text, result
|
65 |
-
|
66 |
# Clean and preprocess text for summarization
|
67 |
def clean_text(text):
|
68 |
text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
|
|
|
38 |
# Initialize device for torch
|
39 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
40 |
|
41 |
+
# Load Whisper model and processor directly using the transformers library
|
42 |
whisper_processor = WhisperProcessor.from_pretrained("NbAiLab/nb-whisper-large")
|
43 |
+
whisper_model = WhisperForConditionalGeneration.from_pretrained("NbAiLab/nb-whisper-large").to(device)
|
44 |
|
45 |
def transcribe_audio(audio_file):
|
46 |
if audio_file.endswith(".m4a"):
|
|
|
62 |
result = f"Time taken: {output_time:.2f} seconds\nNumber of words: {len(text.split())}"
|
63 |
|
64 |
return text, result
|
|
|
65 |
# Clean and preprocess text for summarization
|
66 |
def clean_text(text):
|
67 |
text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
|