Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -48,9 +48,11 @@ def transcribe_audio(audio_file):
|
|
48 |
|
49 |
start_time = time.time()
|
50 |
|
51 |
-
# Load the audio file
|
52 |
-
|
53 |
-
|
|
|
|
|
54 |
|
55 |
# Generate the transcription
|
56 |
output = whisper_model.generate(input_features=input_features)
|
@@ -62,6 +64,7 @@ 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 |
# Clean and preprocess text for summarization
|
66 |
def clean_text(text):
|
67 |
text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
|
|
|
48 |
|
49 |
start_time = time.time()
|
50 |
|
51 |
+
# Load the audio file using torchaudio
|
52 |
+
waveform, sample_rate = torchaudio.load(audio_file)
|
53 |
+
|
54 |
+
# Process the waveform with Whisper's processor
|
55 |
+
input_features = whisper_processor(waveform, sampling_rate=sample_rate, return_tensors="pt").input_features.to(device)
|
56 |
|
57 |
# Generate the transcription
|
58 |
output = whisper_model.generate(input_features=input_features)
|
|
|
64 |
result = f"Time taken: {output_time:.2f} seconds\nNumber of words: {len(text.split())}"
|
65 |
|
66 |
return text, result
|
67 |
+
|
68 |
# Clean and preprocess text for summarization
|
69 |
def clean_text(text):
|
70 |
text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
|