import gradio as gr from tone import StreamingCTCPipeline, read_audio # Load model once at startup pipe = StreamingCTCPipeline.from_hugging_face() def transcribe(audio_path): if audio_path is None: return "Please upload an audio file." try: audio = read_audio(audio_path) result = pipe.forward_offline(audio) # result: list of TextPhrase with text, start_time, end_time return "\n".join([x.text for x in result]) except Exception as e: return f"Error: {str(e)}" with gr.Blocks(title="T-one ASR Demo") as demo: gr.Markdown("# T-one Automatic Speech Recognition Demo") gr.Markdown("Upload an audio file to get real-time transcription using the t-tech/T-one model.") audio_input = gr.Audio(label="Upload Audio File", type="filepath") text_output = gr.Textbox(label="Transcription", placeholder="Transcribed text will appear here...", lines=5) audio_input.change(transcribe, inputs=audio_input, outputs=text_output) demo.launch()