22 lines
700 B
Python
22 lines
700 B
Python
import requests
|
||
|
||
# 本地 FastAPI 服务地址
|
||
url = "http://172.18.127.124:9666/extract_embedding"
|
||
|
||
# 要上传的 WAV 文件路径
|
||
wav_file_path = "/Users/lijinxuan/PycharmProjects/Sea/output1.wav"
|
||
|
||
# 打开文件并发送 POST 请求
|
||
with open(wav_file_path, "rb") as f:
|
||
files = {"wav_file": (f.name, f, "audio/wav")}
|
||
response = requests.post(url, files=files)
|
||
|
||
# 检查响应状态
|
||
if response.status_code == 200:
|
||
result = response.json()
|
||
embedding = result["embedding"]
|
||
print(f"成功提取 embedding,维度: {len(embedding)}")
|
||
print("embedding:", embedding)
|
||
else:
|
||
print(f"请求失败,状态码: {response.status_code}")
|
||
print("错误信息:", response.text) |