Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import torch
|
2 |
from transformers import pipeline
|
3 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
@@ -47,8 +48,9 @@ def transcribe(file, string, return_timestamps):
|
|
47 |
for chunk in timestamps
|
48 |
]
|
49 |
text = "\n".join(str(feature) for feature in timestamps)
|
|
|
50 |
grade = ''
|
51 |
-
if
|
52 |
grade = "good!"
|
53 |
else:
|
54 |
grade = "could use some work..."
|
@@ -64,14 +66,14 @@ mic_transcribe = gr.Interface(
|
|
64 |
gr.inputs.Textbox(label="Word/Phrase"),
|
65 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
66 |
],
|
67 |
-
outputs=["
|
68 |
layout="vertical",
|
69 |
theme="huggingface",
|
70 |
-
title="
|
71 |
description=(
|
72 |
-
"
|
73 |
-
|
74 |
-
" of
|
75 |
),
|
76 |
allow_flagging="never",
|
77 |
)
|
@@ -83,14 +85,14 @@ file_transcribe = gr.Interface(
|
|
83 |
gr.inputs.Textbox(label="Word/Phrase"),
|
84 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
85 |
],
|
86 |
-
outputs=["
|
87 |
layout="vertical",
|
88 |
theme="huggingface",
|
89 |
-
title="
|
90 |
description=(
|
91 |
-
"
|
92 |
-
|
93 |
-
" of
|
94 |
),
|
95 |
examples=[
|
96 |
["./example.flac", "transcribe", False],
|
@@ -101,6 +103,6 @@ file_transcribe = gr.Interface(
|
|
101 |
)
|
102 |
|
103 |
with demo:
|
104 |
-
gr.TabbedInterface([mic_transcribe, file_transcribe], ["
|
105 |
|
106 |
demo.launch(enable_queue=True)
|
|
|
1 |
+
import string
|
2 |
import torch
|
3 |
from transformers import pipeline
|
4 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
|
|
48 |
for chunk in timestamps
|
49 |
]
|
50 |
text = "\n".join(str(feature) for feature in timestamps)
|
51 |
+
text_nopunc = text.translate(str.maketrans('', '', string.punctuation))
|
52 |
grade = ''
|
53 |
+
if text_nopunc.lower() == string.lower():
|
54 |
grade = "good!"
|
55 |
else:
|
56 |
grade = "could use some work..."
|
|
|
66 |
gr.inputs.Textbox(label="Word/Phrase"),
|
67 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
68 |
],
|
69 |
+
outputs=[gr.Textbox(label="What I heard..."), gr.Textbox(label="Grade")],
|
70 |
layout="vertical",
|
71 |
theme="huggingface",
|
72 |
+
title="Vietnamese Pronounciation Checker",
|
73 |
description=(
|
74 |
+
"This space transcribes Vietnamese words, phrases, and sentences via microphone or audio files then compares the user's text input to what the language model hears."
|
75 |
+
"You will then be given a PASS/FAIL grade to tell you if your spoken audio matches the text you entered."
|
76 |
+
f"[{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) is a Vietnamese Speech-to-Text model and powers the analysis of the audio files."
|
77 |
),
|
78 |
allow_flagging="never",
|
79 |
)
|
|
|
85 |
gr.inputs.Textbox(label="Word/Phrase"),
|
86 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
87 |
],
|
88 |
+
outputs=[gr.Textbox(label="What I heard..."), gr.Textbox(label="Grade")],
|
89 |
layout="vertical",
|
90 |
theme="huggingface",
|
91 |
+
title="Vietnamese Pronounciation Checker"",
|
92 |
description=(
|
93 |
+
"This space transcribes Vietnamese words, phrases, and sentences via microphone or audio files then compares the user's text input to what the language model hears."
|
94 |
+
"You will then be given a PASS/FAIL grade to tell you if your spoken audio matches the text you entered."
|
95 |
+
f"[{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) is a Vietnamese Speech-to-Text model and powers the analysis of the audio files."
|
96 |
),
|
97 |
examples=[
|
98 |
["./example.flac", "transcribe", False],
|
|
|
103 |
)
|
104 |
|
105 |
with demo:
|
106 |
+
gr.TabbedInterface([mic_transcribe, file_transcribe], ["Pronounce via Microphone", "Pronounce via Audio File"])
|
107 |
|
108 |
demo.launch(enable_queue=True)
|