Spaces:
Running
on
Zero
Running
on
Zero
mars 5 test script
Browse files- test_tts_mars5.py +50 -0
test_tts_mars5.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from test_overrides import _get_param_examples, _override_params
|
3 |
+
from gradio_client import Client, file
|
4 |
+
|
5 |
+
model = "CAMB-AI/mars5_space"
|
6 |
+
client = Client(model, hf_token=os.getenv('HF_TOKEN'))
|
7 |
+
endpoints = client.view_api(all_endpoints=True, print_info=False, return_format='dict')
|
8 |
+
# print(endpoints)
|
9 |
+
|
10 |
+
api_name = '/on_click'
|
11 |
+
fn_index = None
|
12 |
+
end_parameters = None
|
13 |
+
text = 'This is what my voice sounds like.'
|
14 |
+
|
15 |
+
end_parameters = _get_param_examples(
|
16 |
+
endpoints['named_endpoints'][api_name]['parameters']
|
17 |
+
)
|
18 |
+
print(end_parameters)
|
19 |
+
|
20 |
+
|
21 |
+
space_inputs = end_parameters
|
22 |
+
# override some or all default parameters
|
23 |
+
space_inputs = _override_params(end_parameters, model)
|
24 |
+
|
25 |
+
if(type(space_inputs) == dict):
|
26 |
+
space_inputs['text'] = text
|
27 |
+
result = client.predict(
|
28 |
+
**space_inputs,
|
29 |
+
api_name=api_name,
|
30 |
+
fn_index=fn_index
|
31 |
+
)
|
32 |
+
else:
|
33 |
+
space_inputs[0] = text
|
34 |
+
result = client.predict(
|
35 |
+
*space_inputs,
|
36 |
+
api_name=api_name,
|
37 |
+
fn_index=fn_index
|
38 |
+
)
|
39 |
+
# space_inputs = {str(i): value for i, value in enumerate(space_inputs)}
|
40 |
+
|
41 |
+
print(space_inputs)
|
42 |
+
# print(*space_inputs)
|
43 |
+
# print(**space_inputs)
|
44 |
+
|
45 |
+
# result = client.predict(
|
46 |
+
# **space_inputs,
|
47 |
+
# api_name=api_name,
|
48 |
+
# fn_index=fn_index
|
49 |
+
# )
|
50 |
+
print(result)
|