keshav6936 commited on
Commit
02fee57
1 Parent(s): 4ffb700

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +13 -0
  2. app.py +68 -0
  3. gitattributes +35 -0
  4. requirements.txt +2 -0
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Edge TTS Text To Speech
3
+ emoji: 👁
4
+ colorFrom: pink
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 4.41.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: gpl-2.0
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spaces
2
+ import gradio as gr
3
+ import edge_tts
4
+ import asyncio
5
+ import tempfile
6
+ import os
7
+
8
+ # Get all available voices
9
+ async def get_voices():
10
+ voices = await edge_tts.list_voices()
11
+ return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
12
+
13
+ # Text-to-speech function
14
+ async def text_to_speech(text, voice, rate, pitch):
15
+ if not text.strip():
16
+ return None, gr.Warning("Please enter text to convert.")
17
+ if not voice:
18
+ return None, gr.Warning("Please select a voice.")
19
+
20
+ voice_short_name = voice.split(" - ")[0]
21
+ rate_str = f"{rate:+d}%"
22
+ pitch_str = f"{pitch:+d}Hz"
23
+ communicate = edge_tts.Communicate(text, voice_short_name, rate=rate_str, pitch=pitch_str)
24
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
25
+ tmp_path = tmp_file.name
26
+ await communicate.save(tmp_path)
27
+ return tmp_path, None
28
+
29
+ # Gradio interface function
30
+ @spaces.GPU
31
+ def tts_interface(text, voice, rate, pitch):
32
+ audio, warning = asyncio.run(text_to_speech(text, voice, rate, pitch))
33
+ return audio, warning
34
+
35
+ # Create Gradio application
36
+ import gradio as gr
37
+
38
+ async def create_demo():
39
+ voices = await get_voices()
40
+
41
+ description = """
42
+ Experience the power of Voicecloning.be for text-to-speech conversion.
43
+ """
44
+
45
+ demo = gr.Interface(
46
+ fn=tts_interface,
47
+ inputs=[
48
+ gr.Textbox(label="Input Text", lines=5),
49
+ gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
50
+ gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
51
+ gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
52
+ ],
53
+ outputs=[
54
+ gr.Audio(label="Generated Audio", type="filepath"),
55
+ gr.Markdown(label="Warning", visible=False)
56
+ ],
57
+ title="Voicecloning.be Text-to-Speech",
58
+ description=description,
59
+ article="Experience the power of Voicecloning.be for text-to-speech conversion.",
60
+ analytics_enabled=False,
61
+ allow_flagging=False
62
+ )
63
+ return demo
64
+
65
+ # Run the application
66
+ if __name__ == "__main__":
67
+ demo = asyncio.run(create_demo())
68
+ demo.launch()
gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ edge_tts==6.1.12
2
+ gradio==4.36.1