Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
import time
|
|
@@ -8,13 +29,14 @@ import soundfile as sf
|
|
| 8 |
|
| 9 |
from model import get_pretrained_model, language_to_models
|
| 10 |
|
| 11 |
-
title = "Text-to-speech (TTS)
|
| 12 |
|
| 13 |
description = """
|
| 14 |
This space shows how to convert text to speech with Next-gen Kaldi.
|
| 15 |
|
| 16 |
It is running on CPU within a docker container provided by Hugging Face.
|
| 17 |
|
|
|
|
| 18 |
"""
|
| 19 |
|
| 20 |
# css style is copied from
|
|
@@ -26,10 +48,10 @@ css = """
|
|
| 26 |
.result_item_error {background-color:#ff7070;color:white;align-self:start}
|
| 27 |
"""
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
|
| 35 |
def update_model_dropdown(language: str):
|
|
@@ -128,22 +150,22 @@ with demo:
|
|
| 128 |
placeholder="Please input your text here",
|
| 129 |
)
|
| 130 |
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
|
| 148 |
input_button = gr.Button("Submit")
|
| 149 |
|
|
@@ -151,21 +173,21 @@ with demo:
|
|
| 151 |
|
| 152 |
output_info = gr.HTML(label="Info")
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
|
| 170 |
input_button.click(
|
| 171 |
process,
|
|
@@ -173,8 +195,8 @@ with demo:
|
|
| 173 |
language_radio,
|
| 174 |
model_dropdown,
|
| 175 |
input_text,
|
| 176 |
-
|
| 177 |
-
|
| 178 |
],
|
| 179 |
outputs=[
|
| 180 |
output_audio,
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
#
|
| 3 |
+
# Copyright 2022-2023 Xiaomi Corp. (authors: Fangjun Kuang)
|
| 4 |
+
#
|
| 5 |
+
# See LICENSE for clarification regarding multiple authors
|
| 6 |
+
#
|
| 7 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 |
+
# you may not use this file except in compliance with the License.
|
| 9 |
+
# You may obtain a copy of the License at
|
| 10 |
+
#
|
| 11 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 12 |
+
#
|
| 13 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 14 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 |
+
# See the License for the specific language governing permissions and
|
| 17 |
+
# limitations under the License.
|
| 18 |
+
|
| 19 |
+
# References:
|
| 20 |
+
# https://gradio.app/docs/#dropdown
|
| 21 |
+
|
| 22 |
import logging
|
| 23 |
import os
|
| 24 |
import time
|
|
|
|
| 29 |
|
| 30 |
from model import get_pretrained_model, language_to_models
|
| 31 |
|
| 32 |
+
title = "# Text-to-speech (TTS): Haseeb Ahmed"
|
| 33 |
|
| 34 |
description = """
|
| 35 |
This space shows how to convert text to speech with Next-gen Kaldi.
|
| 36 |
|
| 37 |
It is running on CPU within a docker container provided by Hugging Face.
|
| 38 |
|
| 39 |
+
|
| 40 |
"""
|
| 41 |
|
| 42 |
# css style is copied from
|
|
|
|
| 48 |
.result_item_error {background-color:#ff7070;color:white;align-self:start}
|
| 49 |
"""
|
| 50 |
|
| 51 |
+
examples = [
|
| 52 |
+
["Min-nan (闽南话)", "csukuangfj/vits-mms-nan", "ài piaǸ chiah ē iaN̂", 0, 1.0],
|
| 53 |
+
["Thai", "csukuangfj/vits-mms-tha", "ฉันรักคุณ", 0, 1.0],
|
| 54 |
+
]
|
| 55 |
|
| 56 |
|
| 57 |
def update_model_dropdown(language: str):
|
|
|
|
| 150 |
placeholder="Please input your text here",
|
| 151 |
)
|
| 152 |
|
| 153 |
+
input_sid = gr.Textbox(
|
| 154 |
+
label="Speaker ID",
|
| 155 |
+
info="Speaker ID",
|
| 156 |
+
lines=1,
|
| 157 |
+
max_lines=1,
|
| 158 |
+
value="0",
|
| 159 |
+
placeholder="Speaker ID. Valid only for mult-speaker model",
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
input_speed = gr.Slider(
|
| 163 |
+
minimum=0.1,
|
| 164 |
+
maximum=10,
|
| 165 |
+
value=1,
|
| 166 |
+
step=0.1,
|
| 167 |
+
label="Speed (larger->faster; smaller->slower)",
|
| 168 |
+
)
|
| 169 |
|
| 170 |
input_button = gr.Button("Submit")
|
| 171 |
|
|
|
|
| 173 |
|
| 174 |
output_info = gr.HTML(label="Info")
|
| 175 |
|
| 176 |
+
gr.Examples(
|
| 177 |
+
examples=examples,
|
| 178 |
+
fn=process,
|
| 179 |
+
inputs=[
|
| 180 |
+
language_radio,
|
| 181 |
+
model_dropdown,
|
| 182 |
+
input_text,
|
| 183 |
+
input_sid,
|
| 184 |
+
input_speed,
|
| 185 |
+
],
|
| 186 |
+
outputs=[
|
| 187 |
+
output_audio,
|
| 188 |
+
output_info,
|
| 189 |
+
],
|
| 190 |
+
)
|
| 191 |
|
| 192 |
input_button.click(
|
| 193 |
process,
|
|
|
|
| 195 |
language_radio,
|
| 196 |
model_dropdown,
|
| 197 |
input_text,
|
| 198 |
+
input_sid,
|
| 199 |
+
input_speed,
|
| 200 |
],
|
| 201 |
outputs=[
|
| 202 |
output_audio,
|