Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,8 +6,12 @@ import numpy as np
|
|
6 |
from scipy import signal
|
7 |
import os
|
8 |
|
9 |
-
# Set
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
os.environ['TRANSFORMERS_CACHE'] = cache_dir
|
12 |
os.makedirs(cache_dir, exist_ok=True)
|
13 |
|
@@ -26,12 +30,14 @@ def process_audio(audio_path):
|
|
26 |
predicted_ids = model.generate(**inputs, language="mk")
|
27 |
return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
28 |
|
|
|
29 |
demo = gr.Interface(
|
30 |
fn=process_audio,
|
31 |
inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
|
32 |
outputs="text",
|
33 |
title="Македонско препознавање на говор / Macedonian Speech Recognition",
|
34 |
-
description="Качете аудио или користете микрофон за транскрипција на македонски говор / Upload audio or use microphone to transcribe Macedonian speech"
|
|
|
35 |
)
|
36 |
|
37 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
6 |
from scipy import signal
|
7 |
import os
|
8 |
|
9 |
+
# Set up directories
|
10 |
+
home_dir = os.path.expanduser("~")
|
11 |
+
cache_dir = os.path.join(home_dir, "cache")
|
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 |
|
|
|
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)
|