Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,11 @@ from scipy import signal
|
|
7 |
import os
|
8 |
|
9 |
# Set up directories
|
10 |
-
|
11 |
-
|
12 |
-
flagged_dir = os.path.join(home_dir, "flagged")
|
13 |
|
14 |
-
# Configure cache
|
15 |
-
os.environ['TRANSFORMERS_CACHE'] = cache_dir
|
16 |
os.makedirs(cache_dir, exist_ok=True)
|
|
|
17 |
|
18 |
processor = WhisperProcessor.from_pretrained("openai/whisper-large-v3", cache_dir=cache_dir)
|
19 |
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large-v3", cache_dir=cache_dir)
|
@@ -30,14 +28,15 @@ def process_audio(audio_path):
|
|
30 |
predicted_ids = model.generate(**inputs, language="mk")
|
31 |
return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
32 |
|
33 |
-
# Create Gradio interface with custom flagging directory
|
34 |
demo = gr.Interface(
|
35 |
fn=process_audio,
|
36 |
inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
|
37 |
outputs="text",
|
38 |
title="Македонско препознавање на говор / Macedonian Speech Recognition",
|
39 |
description="Качете аудио или користете микрофон за транскрипција на македонски говор / Upload audio or use microphone to transcribe Macedonian speech",
|
40 |
-
flagging_dir=flagged_dir
|
|
|
|
|
41 |
)
|
42 |
|
43 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
7 |
import os
|
8 |
|
9 |
# Set up directories
|
10 |
+
cache_dir = "/data/cache"
|
11 |
+
flagged_dir = "/data/flagged"
|
|
|
12 |
|
|
|
|
|
13 |
os.makedirs(cache_dir, exist_ok=True)
|
14 |
+
os.makedirs(flagged_dir, exist_ok=True)
|
15 |
|
16 |
processor = WhisperProcessor.from_pretrained("openai/whisper-large-v3", cache_dir=cache_dir)
|
17 |
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large-v3", cache_dir=cache_dir)
|
|
|
28 |
predicted_ids = model.generate(**inputs, language="mk")
|
29 |
return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
30 |
|
|
|
31 |
demo = gr.Interface(
|
32 |
fn=process_audio,
|
33 |
inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
|
34 |
outputs="text",
|
35 |
title="Македонско препознавање на говор / Macedonian Speech Recognition",
|
36 |
description="Качете аудио или користете микрофон за транскрипција на македонски говор / Upload audio or use microphone to transcribe Macedonian speech",
|
37 |
+
flagging_dir=flagged_dir,
|
38 |
+
allow_flagging="manual",
|
39 |
+
flagging_options=["Incorrect Transcription", "Good Transcription"]
|
40 |
)
|
41 |
|
42 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|