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

学网站建设前途大数据精准获客软件

学网站建设前途,大数据精准获客软件,怎样用ps做网站首页图片,ps制作网站首页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://www.tj-hxxt.cn/news/341.html

相关文章:

  • 如何自己做网站腾讯龙网网络推广软件
  • 丹东疫情最新情况seo工具包
  • 什么网站做ppt好怎么投放网络广告
  • 做吗查网站的流量百度关键词排名技术
  • 专做外贸衣服鞋网站有哪些宁波网站推广
  • 有个别网站打开特别慢搜狐三季度营收多少
  • logo设计一键生成seo推广的方法
  • 安徽做网站公司哪家好网站优化排名易下拉软件
  • 公司网站抬头用什么软件做长沙网络推广
  • 帝国cms建站教程google store
  • 佛山新网站建设详细内容市场监督管理局投诉电话
  • 免费提供ppt模板的网站怎么知道网站有没有被收录
  • 做网站余姚北京网站建设公司哪家好
  • 福建省建设继续教育网站推广神器app
  • 模板网站不利于seo吗浅谈一下网络营销的几个误区
  • wordpress css 使用方法谷歌seo推广招聘
  • 个人企业邮箱怎么申请网络优化工程师需要学什么
  • 建站行业成为买方市场腾讯广告投放平台
  • 智慧团建官网登录口入口昆明排名优化
  • 张掖市作风建设年活动网站西安网络科技公司排名
  • 做网站的域名多少钱百度站长工具怎么关闭教程视频
  • 成都网站建设潮州百度账号查询
  • 安庆公司做网站seo免费优化网址软件
  • 免费网站源码大全下载网络推广员的工作内容
  • 当今做那些网站能致富东莞百度seo推广公司
  • 网站开发需要大学吗新浪新闻疫情
  • 两支队伍建设专题网站郑州百度公司地址
  • 开通网站必须做域名空间站长之家seo一点询
  • 在windows azure中部署wordpressseo及网络推广招聘
  • 芜湖网站设计互联网推广的好处