Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,12 +21,12 @@ def guessanAge(model, image):
|
|
21 |
description = imgclassifier(image)
|
22 |
return description
|
23 |
|
24 |
-
def text2speech(model, text):
|
25 |
if len(text) > 0:
|
26 |
synthesiser = pipeline("text-to-speech", model=model)
|
27 |
|
28 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
29 |
-
speaker_embedding = torch.tensor(embeddings_dataset[
|
30 |
|
31 |
speech = synthesiser(text, forward_params={"speaker_embeddings": speaker_embedding})
|
32 |
audio_data = np.frombuffer(speech["audio"], dtype=np.float32)
|
@@ -49,9 +49,10 @@ tab2 = gr.Interface(
|
|
49 |
)
|
50 |
|
51 |
radio3 = gr.Radio(["microsoft/speecht5_tts"], label="Select an tts", info="Age Classifier")
|
|
|
52 |
tab3 = gr.Interface(
|
53 |
fn=text2speech,
|
54 |
-
inputs=[radio3, "text"],
|
55 |
outputs=["audio"],
|
56 |
)
|
57 |
|
|
|
21 |
description = imgclassifier(image)
|
22 |
return description
|
23 |
|
24 |
+
def text2speech(model, text, voice):
|
25 |
if len(text) > 0:
|
26 |
synthesiser = pipeline("text-to-speech", model=model)
|
27 |
|
28 |
embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation")
|
29 |
+
speaker_embedding = torch.tensor(embeddings_dataset[voice]["xvector"]).unsqueeze(0)
|
30 |
|
31 |
speech = synthesiser(text, forward_params={"speaker_embeddings": speaker_embedding})
|
32 |
audio_data = np.frombuffer(speech["audio"], dtype=np.float32)
|
|
|
49 |
)
|
50 |
|
51 |
radio3 = gr.Radio(["microsoft/speecht5_tts"], label="Select an tts", info="Age Classifier")
|
52 |
+
radio3_1 = gr.Radio([("Scottish male", 0), ("US male", 1138), ("US female", 2271), ("Canadian male",3403), ("Indian male", 4535), ("US male", 5667), (6799, "US female")])
|
53 |
tab3 = gr.Interface(
|
54 |
fn=text2speech,
|
55 |
+
inputs=[radio3, "text", radio3_1],
|
56 |
outputs=["audio"],
|
57 |
)
|
58 |
|