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