Spaces:
Sleeping
Sleeping
import gradio as gr | |
from scipy.io import wavfile | |
from wav2vec_aligen import speaker_pronunciation_assesment | |
def analyze_audio(audio): | |
# Write the processed audio to a temporary WAV file | |
if audio is None: | |
return 'the audio is missing' | |
temp_filename = 'temp_audio.wav' | |
wavfile.write(temp_filename, audio[0], audio[1]) | |
result = speaker_pronunciation_assesment(temp_filename) | |
accuracy_score = result['pronunciation_accuracy'] | |
fluency_score = result['fluency_score'] | |
total_score = result['total_score'] | |
content_scores = result['content_scores'] | |
result_markdown = f"""|Language Aspect| Score| | |
|---|---| | |
|Pronunciation Accuracy| {accuracy_score}| | |
|Fluency| {fluency_score}| | |
|Total Score| {total_score}| | |
|Content Score| {content_scores}| | |
""" | |
return result_markdown | |
import gradio as gr | |
CHOICES = ['2861', '2862'] # '2860', | |
AUDIOS = [r'assets/2861.wav', r'assets/2862.wav'] | |
PAIRED_AUDIOS = {k: v for k, v in zip(CHOICES, AUDIOS)} | |
def get_paired_text(value): | |
a_path = PAIRED_AUDIOS.get(value, '') | |
return a_path | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
with gr.Column(): | |
with gr.Row(): | |
drp_down = gr.Dropdown(choices=CHOICES, scale=2) | |
show_text_btn = gr.Button("Select", scale=1) | |
listen_audio = gr.Audio(label='Listen to speech') | |
show_text_btn.click(get_paired_text, inputs=drp_down, outputs=listen_audio) | |
audio_area = gr.Audio(label='Reapet the sentence') | |
analyize_audio_btn = gr.Button("Submit", scale=1) | |
with gr.Column(): | |
capt_area = gr.Markdown(label='CAPT Scores') | |
analyize_audio_btn.click(analyze_audio, inputs=audio_area, outputs=capt_area) | |
demo.launch() | |