Add optional sampling rate
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import base64
|
|
2 |
import random
|
3 |
import requests
|
4 |
import gradio as gr
|
|
|
5 |
|
6 |
SCHEDULE_ME = [
|
7 |
"Hi there, I'm Grant. And I'm on a mission to make local businesses shine.",
|
@@ -506,7 +507,7 @@ RIME_TEXTS = SCHEDULE_ME + SUPERSIZED + MONOPOLY
|
|
506 |
RIME_SPEAKERS = ["marsh", "bayou", "creek", "brook", "flower", "spore", "glacier", "gulch", "alpine", "cove", "lagoon", "tundra", "steppe", "mesa", "grove", "rainforest", "moraine", "wildflower", "peak", "boulder"]
|
507 |
MONOPOLY_SPEAKERS = ["alexis", "audrey", "hannah", "julie", "danielle", "breanna", "jeremy", "ronnie"]
|
508 |
|
509 |
-
def synthesize(key, text, speakers_must, speed, request: gr.Request):
|
510 |
print("Requesting user: ", request.username)
|
511 |
monopoly_sids = MONOPOLY_SPEAKERS
|
512 |
rime_sids = RIME_SPEAKERS
|
@@ -530,13 +531,14 @@ def synthesize(key, text, speakers_must, speed, request: gr.Request):
|
|
530 |
sids = sids_random + sids_must
|
531 |
print(sids)
|
532 |
headers = {"Authorization": "Api-Key {}".format(key)}
|
533 |
-
|
534 |
for i in range(N):
|
535 |
json_data = {
|
536 |
"text": text.lower(),
|
537 |
"speaker": sids[i],
|
538 |
"modelId": "mist",
|
539 |
-
"speedAlpha": speed
|
|
|
540 |
}
|
541 |
print(json_data)
|
542 |
response = requests.post(
|
@@ -556,13 +558,16 @@ gradio_app = gr.Interface(
|
|
556 |
fn=synthesize,
|
557 |
inputs=[
|
558 |
gr.Textbox(
|
559 |
-
type="password", info="This is where you put your Rime TTS API key that was given to you by our team."
|
|
|
|
|
|
|
560 |
),
|
561 |
gr.Textbox(
|
562 |
-
info="
|
563 |
),
|
564 |
gr.Textbox(
|
565 |
-
|
566 |
),
|
567 |
gr.Slider(0.8, 1.2, value=1, label="Speed, higher is slower."),
|
568 |
],
|
|
|
2 |
import random
|
3 |
import requests
|
4 |
import gradio as gr
|
5 |
+
import samplerate
|
6 |
|
7 |
SCHEDULE_ME = [
|
8 |
"Hi there, I'm Grant. And I'm on a mission to make local businesses shine.",
|
|
|
507 |
RIME_SPEAKERS = ["marsh", "bayou", "creek", "brook", "flower", "spore", "glacier", "gulch", "alpine", "cove", "lagoon", "tundra", "steppe", "mesa", "grove", "rainforest", "moraine", "wildflower", "peak", "boulder"]
|
508 |
MONOPOLY_SPEAKERS = ["alexis", "audrey", "hannah", "julie", "danielle", "breanna", "jeremy", "ronnie"]
|
509 |
|
510 |
+
def synthesize(key, text, speakers_must, sampling_rate, speed, request: gr.Request):
|
511 |
print("Requesting user: ", request.username)
|
512 |
monopoly_sids = MONOPOLY_SPEAKERS
|
513 |
rime_sids = RIME_SPEAKERS
|
|
|
531 |
sids = sids_random + sids_must
|
532 |
print(sids)
|
533 |
headers = {"Authorization": "Api-Key {}".format(key)}
|
534 |
+
|
535 |
for i in range(N):
|
536 |
json_data = {
|
537 |
"text": text.lower(),
|
538 |
"speaker": sids[i],
|
539 |
"modelId": "mist",
|
540 |
+
"speedAlpha": speed,
|
541 |
+
"samplingRate": int(sampling_rate) if len(sampling_rate) > 0 else sampling_rate
|
542 |
}
|
543 |
print(json_data)
|
544 |
response = requests.post(
|
|
|
558 |
fn=synthesize,
|
559 |
inputs=[
|
560 |
gr.Textbox(
|
561 |
+
label="Key", type="password", info="This is where you put your Rime TTS API key that was given to you by our team."
|
562 |
+
),
|
563 |
+
gr.Textbox(
|
564 |
+
label="[Optional] Text", info="Enter the text you want synthesized here. If empty, will populate with a sentence at random."
|
565 |
),
|
566 |
gr.Textbox(
|
567 |
+
label="[Optional] Speakers", info="Include speakers that you like, they will stay in the output, comma separated, for example: 'river,oak'"
|
568 |
),
|
569 |
gr.Textbox(
|
570 |
+
label="[Optional] Sampling Rate", info="Default value is 22050"
|
571 |
),
|
572 |
gr.Slider(0.8, 1.2, value=1, label="Speed, higher is slower."),
|
573 |
],
|