NooneImportant flavioschneider commited on
Commit
158b254
0 Parent(s):

Duplicate from elevenlabs/tts

Browse files

Co-authored-by: Flavio <flavioschneider@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. .gitignore +3 -0
  3. README.md +13 -0
  4. app.py +94 -0
  5. requirements.txt +1 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ __pycache__
2
+ .DS_Store
3
+ .mypy_cache
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ElevenLabs TTS
3
+ emoji: 🗣️
4
+ colorFrom: yellow
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 3.40.1
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: elevenlabs/tts
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import gradio as gr
3
+ import numpy as np
4
+ from elevenlabs import voices, generate, set_api_key, UnauthenticatedRateLimitError
5
+
6
+ def pad_buffer(audio):
7
+ # Pad buffer to multiple of 2 bytes
8
+ buffer_size = len(audio)
9
+ element_size = np.dtype(np.int16).itemsize
10
+ if buffer_size % element_size != 0:
11
+ audio = audio + b'\0' * (element_size - (buffer_size % element_size))
12
+ return audio
13
+
14
+ def generate_voice(text, voice_name):
15
+ try:
16
+ audio = generate(
17
+ text[:250], # Limit to 250 characters
18
+ voice=voice_name,
19
+ model="eleven_multilingual_v2"
20
+ )
21
+ return (44100, np.frombuffer(pad_buffer(audio), dtype=np.int16))
22
+ except UnauthenticatedRateLimitError as e:
23
+ raise gr.Error("Thanks for trying out ElevenLabs TTS! You've reached the free tier limit. Please provide an API key to continue.")
24
+ except Exception as e:
25
+ raise gr.Error(e)
26
+
27
+
28
+ badges = """
29
+ <div style="display: flex">
30
+ <span style="margin-right: 5px">
31
+
32
+ [ ![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white) ](https://github.com/elevenlabs/elevenlabs-python)
33
+
34
+ </span>
35
+ <span style="margin-right: 5px">
36
+
37
+ [ ![Twitter](https://img.shields.io/badge/Twitter-%231DA1F2.svg?style=for-the-badge&logo=Twitter&logoColor=white) ](https://twitter.com/elevenlabsio)
38
+
39
+ </span>
40
+ <span>
41
+
42
+ [ ![](https://dcbadge.vercel.app/api/server/elevenlabs) ](https://discord.gg/elevenlabs)
43
+
44
+ </span>
45
+ </div>
46
+ """
47
+
48
+ description = """
49
+ A demo of the world's most advanced TTS systems, made by [ElevenLabs](https://elevenlabs.io). Eleven Multilingual V2 is a single foundational model supporting 28 languages including: English, Chinese, Spanish, Hindi, Portuguese, French, German, Japanese, Arabic, Korean, Indonesian, Italian, Dutch, Turkish, Polish, Swedish, Filipino, Malay, Romanian, Ukrainian, Greek, Czech, Danish, Finnish, Bulgarian, Croatian, Slovak, and Tamil. Sign up on [ElevenLabs](https://elevenlabs.io) to get fast access, long-form generation, voice cloning, API keys, and more!
50
+ """
51
+
52
+ with gr.Blocks() as block:
53
+ gr.Markdown('[ ![ElevenLabs](https://user-images.githubusercontent.com/12028621/262629275-4f85c9cf-85b6-435e-ab50-5b8c7c4e9dd2.png) ](https://elevenlabs.io)')
54
+ gr.Markdown(badges)
55
+ gr.Markdown(description)
56
+
57
+ input_text = gr.Textbox(
58
+ label="Input Text (250 characters max)",
59
+ lines=2,
60
+ value="Hello! 你好! Hola! नमस्ते! Bonjour! こんにちは! مرحبا! 안녕하세요! Ciao! Cześć! Привіт! Γειά σας! Здравей! வணக்கம்!",
61
+ elem_id="input_text"
62
+ )
63
+
64
+ all_voices = voices()
65
+ input_voice = gr.Dropdown(
66
+ [ voice.name for voice in all_voices ],
67
+ value="Bella",
68
+ label="Voice",
69
+ elem_id="input_voice"
70
+ )
71
+
72
+ run_button = gr.Button(
73
+ text="Generate Voice",
74
+ type="button"
75
+ )
76
+
77
+ out_audio = gr.Audio(
78
+ label="Generated Voice",
79
+ type="numpy",
80
+ elem_id="out_audio",
81
+ format="mp3"
82
+ )
83
+
84
+ inputs = [input_text, input_voice]
85
+ outputs = [out_audio]
86
+
87
+ run_button.click(
88
+ fn=generate_voice,
89
+ inputs=inputs,
90
+ outputs=outputs,
91
+ queue=True
92
+ )
93
+
94
+ block.queue(concurrency_count=5).launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ elevenlabs==0.2.15