File size: 1,643 Bytes
e7b9122
1
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: neon-tts-plugin-coqui\n", "### This  demo converts text to speech in 14 languages.\n", "        "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio neon-tts-plugin-coqui==0.4.1a9"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/neon-tts-plugin-coqui/packages.txt"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import tempfile\n", "import gradio as gr\n", "from neon_tts_plugin_coqui import CoquiTTS\n", "\n", "LANGUAGES = list(CoquiTTS.langs.keys())\n", "coquiTTS = CoquiTTS()\n", "\n", "def tts(text: str, language: str):\n", "    with tempfile.NamedTemporaryFile(suffix=\".wav\", delete=False) as fp:\n", "        coquiTTS.get_tts(text, fp, speaker = {\"language\" : language})\n", "        return fp.name\n", "\n", "inputs = [gr.Textbox(label=\"Input\", value=CoquiTTS.langs[\"en\"][\"sentence\"], max_lines=3),\n", "            gr.Radio(label=\"Language\", choices=LANGUAGES, value=\"en\")]\n", "outputs = gr.Audio(label=\"Output\")\n", "\n", "demo = gr.Interface(fn=tts, inputs=inputs, outputs=outputs)\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}