Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,7 @@ from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
-
|
10 |
-
model_id = "openai/whisper-small" # Smaller model for faster response
|
11 |
processor = WhisperProcessor.from_pretrained(model_id)
|
12 |
model = WhisperForConditionalGeneration.from_pretrained(model_id)
|
13 |
|
@@ -23,8 +22,7 @@ def transcribe_audio(audio_url):
|
|
23 |
f.write(response.content)
|
24 |
|
25 |
waveform, sr = librosa.load(audio_path, sr=16000)
|
26 |
-
|
27 |
-
waveform = waveform[:sr * max_duration_sec]
|
28 |
|
29 |
chunk_duration_sec = 25
|
30 |
chunk_size = sr * chunk_duration_sec
|
@@ -48,14 +46,4 @@ def transcribe_endpoint():
|
|
48 |
data = request.get_json()
|
49 |
audio_url = data.get('audio_url')
|
50 |
if not audio_url:
|
51 |
-
return jsonify({"error": "
|
52 |
-
|
53 |
-
try:
|
54 |
-
transcription = transcribe_audio(audio_url)
|
55 |
-
except Exception as e:
|
56 |
-
return jsonify({"error": str(e)}), 500
|
57 |
-
|
58 |
-
return jsonify({"transcription": transcription})
|
59 |
-
|
60 |
-
if __name__ == '__main__':
|
61 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
|
9 |
+
model_id = "openai/whisper-base"
|
|
|
10 |
processor = WhisperProcessor.from_pretrained(model_id)
|
11 |
model = WhisperForConditionalGeneration.from_pretrained(model_id)
|
12 |
|
|
|
22 |
f.write(response.content)
|
23 |
|
24 |
waveform, sr = librosa.load(audio_path, sr=16000)
|
25 |
+
waveform = waveform[:sr * 3600]
|
|
|
26 |
|
27 |
chunk_duration_sec = 25
|
28 |
chunk_size = sr * chunk_duration_sec
|
|
|
46 |
data = request.get_json()
|
47 |
audio_url = data.get('audio_url')
|
48 |
if not audio_url:
|
49 |
+
return jsonify({"error": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|