Spaces:
Runtime error
Runtime error
Delete MyTextToSpeechP.ipynb
Browse files- MyTextToSpeechP.ipynb +0 -122
MyTextToSpeechP.ipynb
DELETED
|
@@ -1,122 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"cells": [
|
| 3 |
-
{
|
| 4 |
-
"cell_type": "code",
|
| 5 |
-
"execution_count": 20,
|
| 6 |
-
"id": "444997da",
|
| 7 |
-
"metadata": {},
|
| 8 |
-
"outputs": [],
|
| 9 |
-
"source": [
|
| 10 |
-
"from gtts import gTTS\n",
|
| 11 |
-
"import gradio as gr\n",
|
| 12 |
-
"import warnings\n",
|
| 13 |
-
"warnings.filterwarnings('ignore')"
|
| 14 |
-
]
|
| 15 |
-
},
|
| 16 |
-
{
|
| 17 |
-
"cell_type": "code",
|
| 18 |
-
"execution_count": 22,
|
| 19 |
-
"id": "0ed11aa4",
|
| 20 |
-
"metadata": {},
|
| 21 |
-
"outputs": [],
|
| 22 |
-
"source": [
|
| 23 |
-
"def textToSpeech(text,lang,file):\n",
|
| 24 |
-
" \n",
|
| 25 |
-
" if file is not None:\n",
|
| 26 |
-
" with open(file.name, \"r\", encoding=\"utf-8\") as f:\n",
|
| 27 |
-
" text = f.read()\n",
|
| 28 |
-
"\n",
|
| 29 |
-
" record=gTTS(text=text,lang=lang,slow=False)\n",
|
| 30 |
-
" record.save(\"output.mp3\")\n",
|
| 31 |
-
" return \"output.mp3\""
|
| 32 |
-
]
|
| 33 |
-
},
|
| 34 |
-
{
|
| 35 |
-
"cell_type": "code",
|
| 36 |
-
"execution_count": 25,
|
| 37 |
-
"id": "accbcaee",
|
| 38 |
-
"metadata": {
|
| 39 |
-
"scrolled": false
|
| 40 |
-
},
|
| 41 |
-
"outputs": [
|
| 42 |
-
{
|
| 43 |
-
"name": "stdout",
|
| 44 |
-
"output_type": "stream",
|
| 45 |
-
"text": [
|
| 46 |
-
"* Running on local URL: http://127.0.0.1:7868\n",
|
| 47 |
-
"\n",
|
| 48 |
-
"To create a public link, set `share=True` in `launch()`.\n"
|
| 49 |
-
]
|
| 50 |
-
},
|
| 51 |
-
{
|
| 52 |
-
"data": {
|
| 53 |
-
"text/html": [
|
| 54 |
-
"<div><iframe src=\"http://127.0.0.1:7868/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 55 |
-
],
|
| 56 |
-
"text/plain": [
|
| 57 |
-
"<IPython.core.display.HTML object>"
|
| 58 |
-
]
|
| 59 |
-
},
|
| 60 |
-
"metadata": {},
|
| 61 |
-
"output_type": "display_data"
|
| 62 |
-
},
|
| 63 |
-
{
|
| 64 |
-
"data": {
|
| 65 |
-
"text/plain": []
|
| 66 |
-
},
|
| 67 |
-
"execution_count": 25,
|
| 68 |
-
"metadata": {},
|
| 69 |
-
"output_type": "execute_result"
|
| 70 |
-
}
|
| 71 |
-
],
|
| 72 |
-
"source": [
|
| 73 |
-
"\n",
|
| 74 |
-
"interface=gr.Interface(\n",
|
| 75 |
-
" fn=textToSpeech,\n",
|
| 76 |
-
" inputs=[gr.Textbox(label='Text to be spoken'),\n",
|
| 77 |
-
" gr.Dropdown(\n",
|
| 78 |
-
" [\"tr\", \"en\", \"fr\", \"de\"], \n",
|
| 79 |
-
" label=\"Language Selection\",\n",
|
| 80 |
-
" value=\"tr\"),\n",
|
| 81 |
-
" gr.File(label=\"Upload Text File(Optional)\",type=\"filepath\")\n",
|
| 82 |
-
" ],\n",
|
| 83 |
-
" outputs=gr.Audio(label=\"Voice\"),\n",
|
| 84 |
-
" title=\"Text To Speech\",\n",
|
| 85 |
-
" description=\"Enter the text you want to voice into the box\"\n",
|
| 86 |
-
" \n",
|
| 87 |
-
")\n",
|
| 88 |
-
"\n",
|
| 89 |
-
"interface.launch()"
|
| 90 |
-
]
|
| 91 |
-
},
|
| 92 |
-
{
|
| 93 |
-
"cell_type": "code",
|
| 94 |
-
"execution_count": null,
|
| 95 |
-
"id": "2030e1b9",
|
| 96 |
-
"metadata": {},
|
| 97 |
-
"outputs": [],
|
| 98 |
-
"source": []
|
| 99 |
-
}
|
| 100 |
-
],
|
| 101 |
-
"metadata": {
|
| 102 |
-
"kernelspec": {
|
| 103 |
-
"display_name": "Python 3 (ipykernel)",
|
| 104 |
-
"language": "python",
|
| 105 |
-
"name": "python3"
|
| 106 |
-
},
|
| 107 |
-
"language_info": {
|
| 108 |
-
"codemirror_mode": {
|
| 109 |
-
"name": "ipython",
|
| 110 |
-
"version": 3
|
| 111 |
-
},
|
| 112 |
-
"file_extension": ".py",
|
| 113 |
-
"mimetype": "text/x-python",
|
| 114 |
-
"name": "python",
|
| 115 |
-
"nbconvert_exporter": "python",
|
| 116 |
-
"pygments_lexer": "ipython3",
|
| 117 |
-
"version": "3.11.5"
|
| 118 |
-
}
|
| 119 |
-
},
|
| 120 |
-
"nbformat": 4,
|
| 121 |
-
"nbformat_minor": 5
|
| 122 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|