import gradio as gr from logic import Speaker_speech_analysis from scipy.io import wavfile def create_html_from_scores(word_scores): html_output = '' for word, score in word_scores: if score == 1: html_output += f'{word} ' elif score == 2: html_output += f'{word} ' else: html_output += f'{word} ' return html_output def generate_progress_bar(score, label): score = round(score, 2) score_text = f"{score:.2f}" if score < 90 else "90" if score < 25: bar_color = "#dc3545" elif score < 50: bar_color = "#dc6545" elif score < 75: bar_color = "#ffc107" else: bar_color = "#28a745" bar_length = f"{(score / 90) * 100}%" return f"""
{html_content}
{pronunciation_progress_bar} {fluency_progress_bar} """ return html_with_css # Define the Gradio interface iface = gr.Interface(fn=analyze_audio, inputs=[gr.Textbox(label='Training Text', placeholder='Write the text for pronunciation task', interactive=True, visible=True, show_copy_button=True,), gr.Audio(label="Recoreded Audio", sources=['microphone', 'upload']) ], outputs=[gr.HTML(label="Analysis of pronunciation"), ], # css=additional_css, # title="Audio Analysis Tool", description="Write any text and recored an audio to predict pronunciation erors" ) # Run the Gradio app if __name__ == "__main__": iface.launch()