Spaces:
Runtime error
Runtime error
no message
Browse files- app.py +13 -11
- nnf_text_to_speech_v1_tester2.py +90 -0
app.py
CHANGED
@@ -6,9 +6,11 @@ from bark.generation import SUPPORTED_LANGS
|
|
6 |
from flask import Flask, jsonify
|
7 |
|
8 |
DEBUG_MODE = False
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
-
#@app.route('/api/test1', methods=['GET'])
|
12 |
def endpoint1():
|
13 |
# Your logic for the first endpoint
|
14 |
#return jsonify({"message": "Endpoint 1"})
|
@@ -16,20 +18,20 @@ def endpoint1():
|
|
16 |
|
17 |
|
18 |
def echo(text, request: gr.Request):
|
|
|
19 |
output_text = {"report1": "SUCCESS"} # Initialize as a dictionary
|
20 |
-
output_text["
|
21 |
if request:
|
22 |
# Convert headers to a dictionary and include them in the output_text
|
23 |
output_text["headers"] = dict(request.headers.items())
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
#audio_out = gr.Audio(label="Generated Audio",
|
30 |
-
# type="numpy", elem_id="audio_out")
|
31 |
-
|
32 |
output_text_json = json.dumps(output_text)
|
33 |
return output_text_json
|
34 |
|
35 |
-
io = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
6 |
from flask import Flask, jsonify
|
7 |
|
8 |
DEBUG_MODE = False
|
9 |
+
EXAMPLES = [
|
10 |
+
["Hello, my name is Suno. And, uh β and I like pizza. [laughs]\nBut I also have other interests such as playing tic tac toe."]
|
11 |
+
]
|
12 |
|
13 |
|
|
|
14 |
def endpoint1():
|
15 |
# Your logic for the first endpoint
|
16 |
#return jsonify({"message": "Endpoint 1"})
|
|
|
18 |
|
19 |
|
20 |
def echo(text, request: gr.Request):
|
21 |
+
|
22 |
output_text = {"report1": "SUCCESS"} # Initialize as a dictionary
|
23 |
+
output_text["your_text"] = text
|
24 |
if request:
|
25 |
# Convert headers to a dictionary and include them in the output_text
|
26 |
output_text["headers"] = dict(request.headers.items())
|
27 |
+
output_text[""]
|
28 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
output_text_json = json.dumps(output_text)
|
30 |
return output_text_json
|
31 |
|
32 |
+
io = gr.Interface(
|
33 |
+
fn = echo,
|
34 |
+
inputs = "textarea",
|
35 |
+
outputs = "json",
|
36 |
+
examples = EXAMPLES
|
37 |
+
).launch(share=True)
|
nnf_text_to_speech_v1_tester2.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Hugging Face's logo
|
2 |
+
Hugging Face
|
3 |
+
Search models, datasets, users...
|
4 |
+
Models
|
5 |
+
Datasets
|
6 |
+
Spaces
|
7 |
+
Posts
|
8 |
+
Docs
|
9 |
+
Pricing
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
Spaces:
|
14 |
+
|
15 |
+
Nuno-Tome
|
16 |
+
/
|
17 |
+
nnf_text_to_speech_v1_tester2
|
18 |
+
private
|
19 |
+
|
20 |
+
App
|
21 |
+
Files
|
22 |
+
Community
|
23 |
+
Settings
|
24 |
+
nnf_text_to_speech_v1_tester2
|
25 |
+
/
|
26 |
+
app.py
|
27 |
+
|
28 |
+
Nuno-Tome's picture
|
29 |
+
Nuno-Tome
|
30 |
+
no message
|
31 |
+
92620bf
|
32 |
+
3 days ago
|
33 |
+
raw
|
34 |
+
history
|
35 |
+
blame
|
36 |
+
edit
|
37 |
+
delete
|
38 |
+
No virus
|
39 |
+
1.55 kB
|
40 |
+
import gradio as gr
|
41 |
+
from gradio_client import Client
|
42 |
+
|
43 |
+
|
44 |
+
DEBUG_MODE = True
|
45 |
+
|
46 |
+
MESAGE_HEADER = """
|
47 |
+
# π£ Neural News Forge project π£
|
48 |
+
## ππ Tester for sand-box/nnf_text_to_speech_v1 ππ
|
49 |
+
### testes for basic GET
|
50 |
+
|
51 |
+
"""
|
52 |
+
|
53 |
+
|
54 |
+
def get_bmc_markdown():
|
55 |
+
bmc_link = "https://www.buymeacoffee.com/nuno.tome"
|
56 |
+
image_url = "https://helloimjessa.files.wordpress.com/2021/06/bmc-button.png" # Image URL
|
57 |
+
image_size = "150" # Image size
|
58 |
+
image_url_full = image_url + "?w=" + image_size
|
59 |
+
image_link_markdown = f"[![Buy Me a Coffee]({image_url_full})]({bmc_link})"
|
60 |
+
full_text = """
|
61 |
+
### If you like this project, please consider liking it or buying me a coffee. It will help me to keep working on this and other projects. Thank you!
|
62 |
+
# """ + image_link_markdown
|
63 |
+
return full_text
|
64 |
+
|
65 |
+
|
66 |
+
def send_request(text):
|
67 |
+
client = Client("sand-box/nnf_text_to_speech_v1")
|
68 |
+
result = client.predict(
|
69 |
+
text,
|
70 |
+
api_name="/predict"
|
71 |
+
)
|
72 |
+
return result
|
73 |
+
|
74 |
+
with gr.Blocks() as demo:
|
75 |
+
|
76 |
+
gr.Markdown(MESAGE_HEADER)
|
77 |
+
#gr.DuplicateButton()
|
78 |
+
#gr.Markdown(get_bmc_markdown())
|
79 |
+
|
80 |
+
with gr.Row():
|
81 |
+
with gr.Column():
|
82 |
+
gr.Markdown("**Type your message:**")
|
83 |
+
inp = gr.TextArea(placeholder="What is your name?")
|
84 |
+
with gr.Column():
|
85 |
+
gr.Markdown("**This is your gradio api request response:**")
|
86 |
+
out = gr.JSON()
|
87 |
+
btn = gr.Button("Send request to server")
|
88 |
+
btn.click(fn=send_request, inputs=inp, outputs=out)
|
89 |
+
|
90 |
+
demo.launch(share=True)
|