真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Python音頻生成器

使用Python生成不同聲音的音頻

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了下城免費(fèi)建站歡迎大家使用!

第一步先去百度AI中注冊(cè)賬號(hào),在控制臺(tái)中創(chuàng)建語(yǔ)音技術(shù)應(yīng)用,獲取AppID,API Key,Secret Key

第二步 引用

from tkinter import *

from tkinter.filedialog import askdirectory

from aip import AipSpeech

from tkinter import ttk

第三步搭建窗體

root = Tk()

root.title('生成語(yǔ)音')

path = StringVar()

pathmc=StringVar()

pathnr=StringVar()

Label(root,text = "保存路徑:").grid(row = 0, column = 0)

Entry(root, textvariable = path).grid(row = 0, column = 1)

Button(root, text = "路徑選擇", command = selectPath).grid(row = 0, column = 3)

Label(root,text = "語(yǔ)音名稱:").grid(row = 2, column = 0)

Entry(root, textvariable = pathmc).grid(row = 2, column = 1)

Label(root,text = "語(yǔ)音內(nèi)容:").grid(row = 3, column = 0)

Entry(root, textvariable = pathnr).grid(row = 3, column = 1)

Button(root, text = "保存", command = Save).grid(row = 4, column = 0)

#下拉框

Label(root,text = "聲音類型:").grid(row =1, column = 0)

number = StringVar()

numberChosen = ttk.Combobox(root, width=12, textvariable=number)

numberChosen['values'] = ('女聲', '男聲', '度逍遙', '度丫丫')

numberChosen.grid(column=1, row=1)

numberChosen.current(0)

root.mainloop()

第四步 創(chuàng)建方法

#保存地址

def selectPath():

path_ = askdirectory()

path.set(path_)

print(path_)

生成音頻的參數(shù)

def Save():

switch = {'女聲': 0,

'男聲': 1,

'度逍遙': 3,

'度丫丫': 4,

}

lx=switch.get(number.get(),"0")

yuying(path.get(),pathmc.get(),pathnr.get(),lx)

#生成音頻

def yuying(url,title,contain,lx):

APP_ID = 'XXX'#百度AI中獲得

API_KEY = 'XXX'

SECRET_KEY = 'XXX'

client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)

result = client.synthesis(contain, 'zh', 1, {

'vol': 5,'per':lx,'spd':2,# per 發(fā)音人選擇, 0為女聲,1為男聲,3為情感合成-度逍遙,4為情感合成-度丫丫,默認(rèn)為普通女 否

})鄭州婦科醫(yī)院 http://www.zzkdfk120.com/

if not isinstance(result, dict):

with open(url+'\\'+title+'.mp3', 'wb') as f:

f.write(result)

合起來(lái)的代碼就是

from tkinter import *

from tkinter.filedialog import askdirectory

from aip import AipSpeech

from tkinter import ttk

def selectPath():

path_ = askdirectory()

path.set(path_)

print(path_)

def Save():

switch = {'女聲': 0,

'男聲': 1,

'度逍遙': 3,

'度丫丫': 4,

}

lx=switch.get(number.get(),"0")

yuying(path.get(),pathmc.get(),pathnr.get(),lx)

def yuying(url,title,contain,lx):

APP_ID = 'XXX'#百度AI中獲得

API_KEY = 'XXX'

SECRET_KEY = 'XXX'

client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)

result = client.synthesis(contain, 'zh', 1, {

'vol': 5,'per':lx,'spd':2,# per 發(fā)音人選擇, 0為女聲,1為男聲,3為情感合成-度逍遙,4為情感合成-度丫丫,默認(rèn)為普通女 否

})

if not isinstance(result, dict):

with open(url+'\\'+title+'.mp3', 'wb') as f:

f.write(result)

root = Tk()

root.title('生成語(yǔ)音')

path = StringVar()

pathmc=StringVar()

pathnr=StringVar()

Label(root,text = "保存路徑:").grid(row = 0, column = 0)

Entry(root, textvariable = path).grid(row = 0, column = 1)

Button(root, text = "路徑選擇", command = selectPath).grid(row = 0, column = 3)

Label(root,text = "語(yǔ)音名稱:").grid(row = 2, column = 0)

Entry(root, textvariable = pathmc).grid(row = 2, column = 1)

Label(root,text = "語(yǔ)音內(nèi)容:").grid(row = 3, column = 0)

Entry(root, textvariable = pathnr).grid(row = 3, column = 1)

Button(root, text = "保存", command = Save).grid(row = 4, column = 0)

Label(root,text = "聲音類型:").grid(row =1, column = 0)

number = StringVar()

numberChosen = ttk.Combobox(root, width=12, textvariable=number)

numberChosen['values'] = ('女聲', '男聲', '度逍遙', '度丫丫')

numberChosen.grid(column=1, row=1)

numberChosen.current(0)

root.mainloop()

效果圖

Python 音頻生成器

網(wǎng)頁(yè)名稱:Python音頻生成器
文章URL:http://weahome.cn/article/jsdodo.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部