From 8bb0ce2e40abc4da3c782d5bc5ef5ac0f31f966f Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Tue, 6 Feb 2024 14:34:02 -0800 Subject: [PATCH] Hotfix for: `stt_or_tts` demo (#7332) * fix * add changeset * add changeset * notebooks --------- Co-authored-by: gradio-pr-bot --- .changeset/petite-years-call.md | 5 +++++ demo/stt_or_tts/run.ipynb | 2 +- demo/stt_or_tts/run.py | 3 +-- gradio/external.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/petite-years-call.md diff --git a/.changeset/petite-years-call.md b/.changeset/petite-years-call.md new file mode 100644 index 0000000000..0842cfc030 --- /dev/null +++ b/.changeset/petite-years-call.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +feat:Hotfix for: `stt_or_tts` demo diff --git a/demo/stt_or_tts/run.ipynb b/demo/stt_or_tts/run.ipynb index 5a5c0a3820..f1608fcaf5 100644 --- a/demo/stt_or_tts/run.ipynb +++ b/demo/stt_or_tts/run.ipynb @@ -1 +1 @@ -{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: stt_or_tts"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "tts_examples = [\n", " \"I love learning machine learning\",\n", " \"How do you do?\",\n", "]\n", "\n", "tts_demo = gr.load(\n", " \"huggingface/facebook/fastspeech2-en-ljspeech\",\n", " title=None,\n", " examples=tts_examples,\n", " description=\"Give me something to say!\",\n", " cache_examples=False\n", ")\n", "\n", "stt_demo = gr.load(\n", " \"huggingface/facebook/wav2vec2-base-960h\",\n", " title=None,\n", " inputs=\"mic\",\n", " description=\"Let me try to guess what you're saying!\",\n", ")\n", "\n", "demo = gr.TabbedInterface([tts_demo, stt_demo], [\"Text-to-speech\", \"Speech-to-text\"])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file +{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: stt_or_tts"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "tts_examples = [\n", " \"I love learning machine learning\",\n", " \"How do you do?\",\n", "]\n", "\n", "tts_demo = gr.load(\n", " \"huggingface/facebook/fastspeech2-en-ljspeech\",\n", " title=None,\n", " examples=tts_examples,\n", " description=\"Give me something to say!\",\n", ")\n", "\n", "stt_demo = gr.load(\n", " \"huggingface/facebook/wav2vec2-base-960h\",\n", " title=None,\n", " inputs=gr.Microphone(type=\"filepath\"),\n", " description=\"Let me try to guess what you're saying!\",\n", ")\n", "\n", "demo = gr.TabbedInterface([tts_demo, stt_demo], [\"Text-to-speech\", \"Speech-to-text\"])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file diff --git a/demo/stt_or_tts/run.py b/demo/stt_or_tts/run.py index 98c97dd376..e364cba3e7 100644 --- a/demo/stt_or_tts/run.py +++ b/demo/stt_or_tts/run.py @@ -10,13 +10,12 @@ tts_demo = gr.load( title=None, examples=tts_examples, description="Give me something to say!", - cache_examples=False ) stt_demo = gr.load( "huggingface/facebook/wav2vec2-base-960h", title=None, - inputs="mic", + inputs=gr.Microphone(type="filepath"), description="Let me try to guess what you're saying!", ) diff --git a/gradio/external.py b/gradio/external.py index c1b2f75442..23b21a4ead 100644 --- a/gradio/external.py +++ b/gradio/external.py @@ -153,7 +153,7 @@ def from_model(model_name: str, hf_token: str | None, alias: str | None, **kwarg fn = custom_post_binary # example model: facebook/wav2vec2-base-960h elif p == "automatic-speech-recognition": - inputs = components.Audio(sources=["upload"], type="filepath", label="Input") + inputs = components.Audio(type="filepath", label="Input") outputs = components.Textbox(label="Output") examples = [ "https://gradio-builds.s3.amazonaws.com/demo-files/audio_sample.wav"