Choose a language to see the code snippets for interacting with the API.
选择一种语言以查看与 API 交互的代码片段。

1. Install the python client (docs) if you don't already have it installed.
1. 如果您还没有安装，请安装 python 客户端 (文档)。

copy
$ pip install gradio_client
2. Find the API endpoint below corresponding to your desired function in the app. Copy the code snippet, replacing the placeholder values with your own input data. If this is a private Space, you may need to pass your Hugging Face token as well (read more). Or use the 
API Recorder

 to automatically generate your API requests.
2. 在下面找到对应您所需功能的 API 端点 在应用中的函数。复制代码片段，替换掉 占位符值用您自己的输入数据替换。 如果这是一个私人空间，您可能需要通过您的 拥抱脸 token 同样适用（阅读更多）。 或者使用 
API 录制器

 自动生成您的 API 请求。

api_name: /add_text
copy
from gradio_client import Client

client = Client("Qwen/Qwen2-Audio-Instruct-Demo")
result = client.predict(
		chatbot=[],
		input={"files":[],"text":""},
		api_name="/add_text"
)
print(result)
Accepts 2 parameters:
chatbot Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None] Default: []

The input value that is provided in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输入值，该值在“Qwen2-Audio-7B-Instruct”Modelscopechatbot 组件中提供。

input Dict(files: List[filepath | str], text: str) Default: {"files":[],"text":""}

The input value that is provided in the "parameter_6" Modelscopemultimodalinput component.
parameter_6 模型域多模态输入组件中提供的输入值。

Returns tuple of 2 elements
[0] Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None]

The output value that appears in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输出值出现在“Qwen2-Audio-7B-Instruct”模型 Scopechatbot 组件中。

[1] Dict(files: List[filepath | str], text: str)

The output value that appears in the "value_6" Modelscopemultimodalinput component.
输出值出现在“value_6”Modelscopemultimodalinput 组件中。

api_name: /predict
copy
from gradio_client import Client

client = Client("Qwen/Qwen2-Audio-Instruct-Demo")
result = client.predict(
		chatbot=[],
		api_name="/predict"
)
print(result)
Accepts 1 parameter:
chatbot Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None] Default: []

The input value that is provided in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输入值，该值在“Qwen2-Audio-7B-Instruct”Modelscopechatbot 组件中提供。

Returns 1 element
Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None]

The output value that appears in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输出值出现在“Qwen2-Audio-7B-Instruct”模型 Scopechatbot 组件中。

api_name: /reset_state
copy
from gradio_client import Client

client = Client("Qwen/Qwen2-Audio-Instruct-Demo")
result = client.predict(
		api_name="/reset_state"
)
print(result)
Accepts 0 parameters:
Returns 1 element
Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None]

The output value that appears in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输出值出现在“Qwen2-Audio-7B-Instruct”模型 Scopechatbot 组件中。

api_name: /regenerate
copy
from gradio_client import Client

client = Client("Qwen/Qwen2-Audio-Instruct-Demo")
result = client.predict(
		chatbot=[],
		api_name="/regenerate"
)
print(result)
Accepts 1 parameter:
chatbot Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None] Default: []

The input value that is provided in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输入值，该值在“Qwen2-Audio-7B-Instruct”Modelscopechatbot 组件中提供。

Returns 1 element
Tuple[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None, Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | List[Dict(id: str | None, elem_id: str | None, elem_classes: str | List[str] | None, name: str | None, text: str | None, flushing: bool | None, avatar: str | filepath | None, files: List[Dict(file: filepath, alt_text: str | None) | Dict() | filepath | str | str] | None) | Dict(files: List[filepath | str], text: str) | Dict() | str | None] | None]

The output value that appears in the "Qwen2-Audio-7B-Instruct" Modelscopechatbot component.
输出值出现在“Qwen2-Audio-7B-Instruct”模型 Scopechatbot 组件中。
--------
给我实现一个程序，用于提升普通话水平，大概就是用户点击录音，然后将录音和对应的提示词请求这个接口，最后将接口返回结果展示给用户