Python GET 语音合成接口并播放

180it 2019-09-28 AM 593℃ 0条

import requests
import simplejson as json
import urllib
import pygame
import time
import os

请求地址

url = "http://123.57.228.55:49669/?ID=0&YP=32kHz8BitMono&SD=0&ReadText=大家凌晨好"

发送get请求

r = requests.get(url)

s = json.loads(r.json())

print(r.json())
downurl=r.json()["url"]
print(downurl)
print("下载音频文件...")
time.sleep(3)

newFile=requests.get(downurl)
with open("test.wav","wb") as fp:

 fp.write(newFile.content)

print("准备播放...")
time.sleep(2)
file='test.wav'#文件名是完整路径名
os.system(file)

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

Python GET 语音合成接口并播放