91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Python 音頻生成器

發布時間:2020-07-03 07:55:37 來源:網絡 閱讀:426 作者:nineteens 欄目:編程語言

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

  第一步先去百度AI中注冊賬號,在控制臺中創建語音技術應用,獲取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('生成語音')

  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 = "語音名稱:").grid(row = 2, column = 0)

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

  Label(root,text = "語音內容:").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()

  第四步 創建方法

  #保存地址

  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 發音人選擇, 0為女聲,1為男聲,3為情感合成-度逍遙,4為情感合成-度丫丫,默認為普通女 否

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

  if not isinstance(result, dict):

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

  f.write(result)

  合起來的代碼就是

  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 發音人選擇, 0為女聲,1為男聲,3為情感合成-度逍遙,4為情感合成-度丫丫,默認為普通女 否

  })

  if not isinstance(result, dict):

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

  f.write(result)

  root = Tk()

  root.title('生成語音')

  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 = "語音名稱:").grid(row = 2, column = 0)

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

  Label(root,text = "語音內容:").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 音頻生成器


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

五常市| 宁武县| 吐鲁番市| 神农架林区| 大石桥市| 双鸭山市| 勐海县| 万山特区| 舞钢市| 天峻县| 库车县| 上虞市| 新竹市| 普陀区| 新密市| 额尔古纳市| 丘北县| 康保县| 许昌县| 福安市| 汾阳市| 江华| 南通市| 贵定县| 湘阴县| 长泰县| 平邑县| 门头沟区| 潞城市| 巴南区| 竹北市| 上饶县| 博兴县| 平遥县| 叶城县| 安乡县| 苍溪县| 枣强县| 马鞍山市| 尼玛县| 梅河口市|