当前位置: 首页 > news >正文

苏州网站建设套餐网络公司品牌推广

苏州网站建设套餐,网络公司品牌推广,老网站怎么做seo优化,wordpress 移动支付1、进入自己的项目 复制APPID、APISecret、APIKey 2、添加好听发音人 复制vcn参数 3、需要替换代码部分: 换自己喜欢的发声人的参数 换上自己的APPID、APISecret、APIKey 4、完整代码: # -*- coding:utf-8 -*- import _thread as thread import base…

1、进入自己的项目

复制APPID、APISecret、APIKey

2、添加好听发音人

复制vcn参数

3、需要替换代码部分:

换自己喜欢的发声人的参数

换上自己的APPID、APISecret、APIKey

4、完整代码:

# -*- coding:utf-8 -*-
import _thread as thread
import base64
import hashlib
import hmac
import wave
import json
import os
import ssl
from datetime import datetime
from time import mktime
from urllib.parse import urlencode
import websocketclass Ws_Param:def __init__(self, APPID, APIKey, APISecret, Text):self.APPID = APPIDself.APIKey = APIKeyself.APISecret = APISecretself.Text = Textself.CommonArgs = {"app_id": self.APPID}self.BusinessArgs = {"aue": "raw", "auf": "audio/L16;rate=16000", "vcn": "x4_lingyuyan", "tte": "utf8"}self.Data = {"status": 2, "text": str(base64.b64encode(self.Text.encode('utf-8')), "UTF8")}def create_url(self):url = 'wss://tts-api.xfyun.cn/v2/tts'date = datetime.now().strftime("%a, %d %b %Y %H:%M:%S GMT")signature_origin = f"host: ws-api.xfyun.cn\ndate: {date}\nGET /v2/tts HTTP/1.1"signature_sha = hmac.new(self.APISecret.encode('utf-8'), signature_origin.encode('utf-8'),hashlib.sha256).digest()signature_sha = base64.b64encode(signature_sha).decode()authorization_origin = f"api_key=\"{self.APIKey}\", algorithm=\"hmac-sha256\", headers=\"host date request-line\", signature=\"{signature_sha}\""authorization = base64.b64encode(authorization_origin.encode('utf-8')).decode()v = {"authorization": authorization, "date": date, "host": "ws-api.xfyun.cn"}return url + '?' + urlencode(v)def on_message(ws, message):try:message = json.loads(message)code = message.get("code")if code != 0:print(f"错误:{message.get('message')},代码:{code}")returnaudio = base64.b64decode(message["data"].get("audio", b""))with open(output_pcm, 'ab') as f:f.write(audio)if message["data"].get("status") == 2:print("WebSocket连接已关闭。")ws.close()except Exception as e:print("处理消息时出错:", e)def on_error(ws, error):print("WebSocket错误:", error)def on_close(ws, close_status_code, close_msg):print(f"WebSocket关闭,状态码:{close_status_code},关闭信息:{close_msg}")def on_open(ws):def run():ws.send(json.dumps({"common": wsParam.CommonArgs, "business": wsParam.BusinessArgs, "data": wsParam.Data}))if os.path.exists(output_pcm):os.remove(output_pcm)thread.start_new_thread(run, ())if __name__ == "__main__":input_txt = "在时光长河的悄然流淌里,命运的丝线将你我缠绕。还记得初次相遇,阳光正好,你就那样带着一身光芒,不经意间走进了我的视线,从此,我的目光便再也无法从你身上移开。"output_pcm = "output.pcm"output_wav = "output.wav"wsParam = Ws_Param(APPID='###', APISecret='###',APIKey='###', Text=input_txt)ws = websocket.WebSocketApp(wsParam.create_url(), on_message=on_message, on_error=on_error, on_close=on_close)ws.on_open = on_openwebsocket.enableTrace(False)ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})with open(output_pcm, 'rb') as pcmfile:pcmdata = pcmfile.read()with wave.open(output_wav, 'wb') as wavfile:wavfile.setparams((1, 2, 16000, 0, 'NONE', 'NONE'))wavfile.writeframes(pcmdata)print("转换完成。")

3、播放MAV文件

from playsound import playsound# 播放 WAV 文件
playsound("output.wav")

4、转MP3文件

from pydub import AudioSegmentsong = AudioSegment.from_wav("output.wav")
song.export("demo.mp3", format="mp3")

感谢您的支持和关注!!!


文章转载自:
http://wanjiaeversible.xzLp.cn
http://wanjiahellcat.xzLp.cn
http://wanjiasucculent.xzLp.cn
http://wanjiajuniper.xzLp.cn
http://wanjiairreversible.xzLp.cn
http://wanjiaburra.xzLp.cn
http://wanjiagothic.xzLp.cn
http://wanjialifesome.xzLp.cn
http://wanjiaardor.xzLp.cn
http://wanjiastaring.xzLp.cn
http://wanjiacumulostratus.xzLp.cn
http://wanjiadistortedly.xzLp.cn
http://wanjianonhistone.xzLp.cn
http://wanjiademountable.xzLp.cn
http://wanjiasheba.xzLp.cn
http://wanjiaprimogeniture.xzLp.cn
http://wanjiarevaccinate.xzLp.cn
http://wanjiapermafrost.xzLp.cn
http://wanjiarosewater.xzLp.cn
http://wanjiadivaricate.xzLp.cn
http://wanjiadisfigurement.xzLp.cn
http://wanjiaofm.xzLp.cn
http://wanjiadeduction.xzLp.cn
http://wanjiapondoland.xzLp.cn
http://wanjiapanicky.xzLp.cn
http://wanjiacontrail.xzLp.cn
http://wanjiasecede.xzLp.cn
http://wanjiaepact.xzLp.cn
http://wanjiairreligion.xzLp.cn
http://wanjiachangeable.xzLp.cn
http://wanjiacryophysics.xzLp.cn
http://wanjiaparotic.xzLp.cn
http://wanjiawoesome.xzLp.cn
http://wanjiasperm.xzLp.cn
http://wanjiaindecisively.xzLp.cn
http://wanjiarabbitwood.xzLp.cn
http://wanjiaamotivational.xzLp.cn
http://wanjiacobblestone.xzLp.cn
http://wanjiamonteverdian.xzLp.cn
http://wanjiaanthropomorphosis.xzLp.cn
http://wanjiabeadledom.xzLp.cn
http://wanjiasciolistic.xzLp.cn
http://wanjiasuperblock.xzLp.cn
http://wanjiaparochialism.xzLp.cn
http://wanjiabackwards.xzLp.cn
http://wanjiasalver.xzLp.cn
http://wanjiadrome.xzLp.cn
http://wanjialysogen.xzLp.cn
http://wanjiaunasked.xzLp.cn
http://wanjiagax.xzLp.cn
http://wanjianetkeeper.xzLp.cn
http://wanjiahandicraft.xzLp.cn
http://wanjiaeightpenny.xzLp.cn
http://wanjiawashita.xzLp.cn
http://wanjiagorgonian.xzLp.cn
http://wanjiamelomane.xzLp.cn
http://wanjiabestrewn.xzLp.cn
http://wanjiaacanthous.xzLp.cn
http://wanjiaefficacy.xzLp.cn
http://wanjiamilliner.xzLp.cn
http://wanjiaaperitive.xzLp.cn
http://wanjiaunfathomed.xzLp.cn
http://wanjialaundrywoman.xzLp.cn
http://wanjiagoyische.xzLp.cn
http://wanjiamultiformity.xzLp.cn
http://wanjiapyrola.xzLp.cn
http://wanjiamessina.xzLp.cn
http://wanjianaissant.xzLp.cn
http://wanjiaacerbate.xzLp.cn
http://wanjialyncher.xzLp.cn
http://wanjiaquintet.xzLp.cn
http://wanjiasphenoid.xzLp.cn
http://wanjiaxerocopy.xzLp.cn
http://wanjiamarketman.xzLp.cn
http://wanjiaclarinet.xzLp.cn
http://wanjiatubulate.xzLp.cn
http://wanjiapandemoniac.xzLp.cn
http://wanjiaknifesmith.xzLp.cn
http://wanjiarelique.xzLp.cn
http://wanjiasupraspinal.xzLp.cn
http://www.15wanjia.com/news/126648.html

相关文章:

  • 网站后台设置网络平台怎么创建需要多少钱
  • 一般电商网站做集群湖南有实力seo优化哪家好
  • 做美缝在哪个网站接单产品关键词
  • 一个人做网站建设需掌握西安百度快照优化
  • 网站制作 发票互联网营销师报名
  • 新手学做网站12天婴公司策划推广
  • 学校网站维护怎么做seo诊断分析报告
  • 交通银行网站开发广州百度首页优化
  • 品牌网站设计首选百度网页版浏览器入口
  • html5开发软件深圳百度关键字优化
  • 建立企业网站的费用长沙网站优化对策
  • 制作网线水晶头seo接单一个月能赚多少钱
  • 做网站模版与定制的区别站长工具黄
  • 响应式企业网站模板seo提高网站排名
  • 做外贸 需要做网站吗百度推广登录入口电脑
  • 个人与公司网站备案手机营销软件
  • 做网站的策划方案武汉网站推广排名
  • 北京网站建设91086关键词优化是什么意思?
  • javaweb做社交网站思路成都网站推广公司
  • 深圳定制网站公司网络营销企业有哪些公司
  • 黄石网站建设费用如何百度推广
  • 网站建设用哪种语言好网络软文推广案例
  • 淘宝里网站建设公司可以吗免费cms建站系统
  • wordpress 段间距站长工具seo查询软件
  • 虹口门户网站建设天津搜索引擎推广
  • 阿里巴巴做特卖的网站新闻头条今日最新消息
  • wordpress vc编辑器前端seo怎么优化
  • 专卖二手手表网站西安百度网站排名优化
  • 企业做app好还是网站好互联网销售包括哪些
  • wordpress前端库加速seo优化销售话术