import tkinter as tk from PIL import ImageTk from aip import AipSpeech import os window = tk.Tk() window.geometry('1050x591') window.resizable(0,0) window.title('小说阅读器') def voice(): appId = '24851802' apiKey = 'gmFwxHASuifsG7Kdla5Pjgjl' secretKey = 'xFf5ZSCdDwQGmc099UsFh9mBY3GIfy6C' #请在下方书写你的代码 #合成语音 client = AipSpeech(appId,apiKey,secretKey) result = client.synthesis(content,'zh',1,{'vol':1,'per':0,'spd':4}) mp3name = "voices/audio1.mp3" if not isinstance(result,dict): with open(mp3name,'wb') as f: f.write(result) #跳转文件 os.system('python voice.py %s' %mp3name) bgImg = ImageTk.PhotoImage(file="images/bg.png") bg = tk.Label(window,width=1050,height=591,image=bgImg) bg.pack() okImg = ImageTk.PhotoImage(file="images/ok.png") #请在下方书写你的代码 #绑定函数 ok = tk.Button(window,width=135,height=43,image=okImg,bd=0,command=voice) ok.place(x=455,y=540) #请在下方书写你的代码 #显示多行文本 with open('novel.txt','r',encoding='utf-8') as f: content = f.read() text = tk.Text(window,width=55,height=15,bg='#FFFFFF',font=("font/simhei.ttf",18)) text.place(x=190,y=115) text.insert(tk.INSERT,content) window.mainloop()
import pygame import sys pygame.init() canvas = pygame.display.set_mode((60,60)) #请在下方书写你的代码 #播放语音 mp3name = sys.argv[1] pygame.mixer.music.load(mp3name) pygame.mixer.music.play() while True: for event in pygame.event.get(): if event.type == pygame.QUIT: exit() pygame.display.update()
标签:bg,mp3name,window,pygame,阅读器,import,小说,tk From: https://www.cnblogs.com/jyssh/p/17135126.html