Spaces:
Running
on
T4
Running
on
T4
georg-suno
commited on
Commit
•
2adbf1a
1
Parent(s):
1892f86
more updates
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
from bark import SAMPLE_RATE, generate_audio, preload_models
|
4 |
from bark.generation import SUPPORTED_LANGS
|
5 |
|
6 |
-
DEBUG_MODE =
|
7 |
|
8 |
if not DEBUG_MODE:
|
9 |
_ = preload_models()
|
@@ -20,24 +20,119 @@ PROMPT_LOOKUP["Announcer"] = "announcer"
|
|
20 |
|
21 |
default_text = "Hello, my name is Suno. And, uh — and I like pizza. [laughs]\nBut I also have other interests such as playing tic tac toe."
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
def gen_tts(text, history_prompt, temp_semantic, temp_waveform):
|
24 |
history_prompt = PROMPT_LOOKUP[history_prompt]
|
25 |
if DEBUG_MODE:
|
26 |
audio_arr = np.zeros(SAMPLE_RATE)
|
27 |
else:
|
28 |
audio_arr = generate_audio(text, history_prompt=history_prompt, text_temp=temp_semantic, waveform_temp=temp_waveform)
|
|
|
29 |
return (SAMPLE_RATE, audio_arr)
|
30 |
|
31 |
iface = gr.Interface(
|
32 |
-
title="<div style='text-align:left'>🐶 Bark</div>",
|
33 |
-
description="Bark is a universal text-to-audio model created by [Suno](www.suno.ai), with code publicly available [here](https://github.com/suno-ai/bark). Bark can generate highly realistic, multilingual speech as well as other audio - including music, background noise and simple sound effects. This demo should be used for research purposes only. Commercial use is strictly prohibited. The model output is not censored and the authors do not endorse the opinions in the generated content. Use at your own risk.",
|
34 |
fn=gen_tts,
|
35 |
inputs=[
|
36 |
-
gr.Textbox(label="Input Text", lines=
|
37 |
-
gr.Dropdown(AVAILABLE_PROMPTS, value="
|
38 |
-
gr.Slider(minimum=0, maximum=1, step=0.01, value=0.7, label="Temp 1", info="Gen. temperature of semantic tokens. (lower is more conservative, higher is more diverse)"),
|
39 |
-
gr.Slider(minimum=0, maximum=1, step=0.01, value=0.7, label="Temp 2", info="Gen. temperature of waveform tokens. (lower is more conservative, higher is more diverse)"),
|
40 |
],
|
41 |
-
outputs=
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from bark import SAMPLE_RATE, generate_audio, preload_models
|
4 |
from bark.generation import SUPPORTED_LANGS
|
5 |
|
6 |
+
DEBUG_MODE = True
|
7 |
|
8 |
if not DEBUG_MODE:
|
9 |
_ = preload_models()
|
|
|
20 |
|
21 |
default_text = "Hello, my name is Suno. And, uh — and I like pizza. [laughs]\nBut I also have other interests such as playing tic tac toe."
|
22 |
|
23 |
+
title = "<div style='text-align:left'>🐶 Bark</div>"
|
24 |
+
|
25 |
+
description = """
|
26 |
+
<a href='https://github.com/suno-ai/bark'><img src='https://img.shields.io/github/stars/suno-ai/bark?style=social' /></a>
|
27 |
+
Bark is a universal text-to-audio model created by [Suno](www.suno.ai), with code publicly available [here](https://github.com/suno-ai/bark). \
|
28 |
+
Bark can generate highly realistic, multilingual speech as well as other audio - including music, background noise and simple sound effects. \
|
29 |
+
This demo should be used for research purposes only. Commercial use is strictly prohibited. \
|
30 |
+
The model output is not censored and the authors do not endorse the opinions in the generated content. \
|
31 |
+
Use at your own risk.
|
32 |
+
"""
|
33 |
+
|
34 |
+
article = """
|
35 |
+
|
36 |
+
## 🌎 Foreign Language
|
37 |
+
|
38 |
+
Bark supports various languages out-of-the-box and automatically determines language from input text. \
|
39 |
+
When prompted with code-switched text, Bark will even attempt to employ the native accent for the respective languages in the same voice.
|
40 |
+
|
41 |
+
Try the prompt:
|
42 |
+
|
43 |
+
```
|
44 |
+
Buenos días Miguel. Tu colega piensa que tu alemán es extremadamente malo. But I suppose your english isn't terrible.
|
45 |
+
```
|
46 |
+
|
47 |
+
## 🤭 Non-Speech Sounds
|
48 |
+
|
49 |
+
Below is a list of some known non-speech sounds, but we are finding more every day. \
|
50 |
+
Please let us know if you find patterns that work particularly well on Discord!
|
51 |
+
|
52 |
+
* [laughter]
|
53 |
+
* [laughs]
|
54 |
+
* [sighs]
|
55 |
+
* [music]
|
56 |
+
* [gasps]
|
57 |
+
* [clears throat]
|
58 |
+
* — or ... for hesitations
|
59 |
+
* ♪ for song lyrics
|
60 |
+
* capitalization for emphasis of a word
|
61 |
+
* MAN/WOMAN: for bias towards speaker
|
62 |
+
|
63 |
+
Try the prompt:
|
64 |
+
|
65 |
+
```
|
66 |
+
" [clears throat] Hello, my name is Suno. And, uh — and I like pizza. [laughs] But I also have other interests such as... ♪ singing ♪."
|
67 |
+
```
|
68 |
+
|
69 |
+
## 🎶 Music
|
70 |
+
Bark can generate all types of audio, and, in principle, doesn't see a difference between speech and music. \
|
71 |
+
Sometimes Bark chooses to generate text as music, but you can help it out by adding music notes around your lyrics.
|
72 |
+
|
73 |
+
Try the prompt:
|
74 |
+
|
75 |
+
```
|
76 |
+
♪ In the jungle, the mighty jungle, the lion barks tonight ♪
|
77 |
+
```
|
78 |
+
|
79 |
+
## 🧬 Voice Cloning
|
80 |
+
|
81 |
+
Bark has the capability to fully clone voices - including tone, pitch, emotion and prosody. \
|
82 |
+
The model also attempts to preserve music, ambient noise, etc. from input audio. \
|
83 |
+
However, to mitigate misuse of this technology, we limit the audio history prompts to a limited set of Suno-provided, fully synthetic options to choose from.
|
84 |
+
|
85 |
+
## 👥 Speaker Prompts
|
86 |
+
|
87 |
+
You can provide certain speaker prompts such as NARRATOR, MAN, WOMAN, etc. \
|
88 |
+
Please note that these are not always respected, especially if a conflicting audio history prompt is given.
|
89 |
+
|
90 |
+
Try the prompt:
|
91 |
+
|
92 |
+
```
|
93 |
+
WOMAN: I would like an oatmilk latte please.
|
94 |
+
MAN: Wow, that's expensive!
|
95 |
+
```
|
96 |
+
|
97 |
+
## Details
|
98 |
+
|
99 |
+
Bark model by [Suno](https://suno.ai/), including official [code](https://github.com/suno-ai/bark) and model weights. Gradio demo supported by 🤗 Hugging Face. Bark is licensed under a non-commercial license: CC-BY 4.0 NC, see details on [GitHub](https://github.com/suno-ai/bark).
|
100 |
+
|
101 |
+
|
102 |
+
"""
|
103 |
+
|
104 |
+
examples = [
|
105 |
+
["Please surprise me and speak in whatever voice you enjoy.", "Unconditional", 0.7, 0.7],
|
106 |
+
["Hello, my name is Suno. And, uh — and I like pizza. [laughs] But I also have other interests such as playing tic tac toe.", "Speaker 1 (en)", 0.7, 0.7],
|
107 |
+
["Buenos días Miguel. Tu colega piensa que tu alemán es extremadamente malo. But I suppose your english isn't terrible.", "Speaker 0 (es)", 0.7, 0.7],
|
108 |
+
]
|
109 |
+
|
110 |
+
|
111 |
def gen_tts(text, history_prompt, temp_semantic, temp_waveform):
|
112 |
history_prompt = PROMPT_LOOKUP[history_prompt]
|
113 |
if DEBUG_MODE:
|
114 |
audio_arr = np.zeros(SAMPLE_RATE)
|
115 |
else:
|
116 |
audio_arr = generate_audio(text, history_prompt=history_prompt, text_temp=temp_semantic, waveform_temp=temp_waveform)
|
117 |
+
audio_array = (audio_array * 32767).astype(np.int16)
|
118 |
return (SAMPLE_RATE, audio_arr)
|
119 |
|
120 |
iface = gr.Interface(
|
|
|
|
|
121 |
fn=gen_tts,
|
122 |
inputs=[
|
123 |
+
gr.Textbox(label="Input Text", lines=2, value=default_text),
|
124 |
+
gr.Dropdown(AVAILABLE_PROMPTS, value="Speaker 1 (en)", label="Acoustic Prompt"),
|
125 |
+
# gr.Slider(minimum=0, maximum=1, step=0.01, value=0.7, label="Temp 1", info="Gen. temperature of semantic tokens. (lower is more conservative, higher is more diverse)"),
|
126 |
+
# gr.Slider(minimum=0, maximum=1, step=0.01, value=0.7, label="Temp 2", info="Gen. temperature of waveform tokens. (lower is more conservative, higher is more diverse)"),
|
127 |
],
|
128 |
+
outputs=[
|
129 |
+
gr.Audio(label="Generated Audio", type="numpy"),
|
130 |
+
],
|
131 |
+
title=title,
|
132 |
+
description=description,
|
133 |
+
article=article,
|
134 |
+
examples=examples,
|
135 |
+
cache_examples=False,
|
136 |
+
)
|
137 |
+
|
138 |
+
iface.launch(enable_queue=True)
|