We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问是必须在colab上本地调用吗?还是可以在其他服务器通过公网地址来调用api? 没看到相关文档,不是很清楚,谢谢 以下是我的代码
import requests api_url = "https://xxxxx71b02a286.gradio.live/" params = { "text": "我是一个充满活力的人,喜欢运动,喜欢旅行,喜欢尝试新鲜事物。我喜欢挑战自己,不断突破自己的极限,让自己变得更加强大。我是一个充满活力的人,喜欢运动,喜欢旅行,喜欢尝试新鲜事物。我喜欢挑战自己,不断突破自己的极限,让自己变得更加强大。", "media_type": "wav", "seed": 2581, "streaming": 0 # 如果需要流式输出,设置为1 } # 发送GET请求 try: response = requests.get(api_url, params=params) response.raise_for_status() # 检查响应状态 # 打印状态码和响应头 print("Status code:", response.status_code) print("Response headers:", response.headers) print("Response content length:", len(response.content)) # 检查内容类型 content_type = response.headers.get('Content-Type') print("Content-Type:", content_type) if 'audio' in content_type: # 保存音频文件 with open("output.wav", "wb") as f: f.write(response.content) print("音频文件已保存为 output.wav") else: print("返回的不是音频文件,内容类型为:", content_type) with open("response.html", "wb") as f: f.write(response.content) print("响应内容已保存为 response.html 以供检查") except requests.exceptions.RequestException as e: print(f"请求失败:{e}")
执行后最后返回的是response.html把前端页面返回来了...
The text was updated successfully, but these errors were encountered:
同问
Sorry, something went wrong.
No branches or pull requests
请问是必须在colab上本地调用吗?还是可以在其他服务器通过公网地址来调用api?
没看到相关文档,不是很清楚,谢谢
以下是我的代码
执行后最后返回的是response.html把前端页面返回来了...
The text was updated successfully, but these errors were encountered: