基于Python编写简易文字语音转换器
话不多说上代码!源代码
from tkinter import *
import pyttsx3
class Application(Frame):
def __init__(self,master=None):
super().__init__(master)
self.master = master
self.pack()
self.creatWidget()
# BING INPUT
def creatWidget(self):
self.w1 = Text(self, width=80, heigh=40, bg="lightcyan") # 宽度为80个字母(40个汉字),高度为1个行高
self.w1.pack()
Button(self, text="转语音", command=self.returnText).pack(side="left")
# 返回信息
def returnText(self):
# Indexes(索引):用来指向Text组件中文本的位置,Text的组件索引也是对应实际字符之间的位置
# 行号以1开始,列号以0开始
result=self.w1.get(1.0, END)
# print("所有文本内容:\n", result)
# messagebox.showinfo("所有的文本", self.w1.get(1.0, END))
engine = pyttsx3.init()
engine.say(result)
engine.runAndWait()
if __name__ == "__main__":
root = Tk()
root.geometry("800x600+10+10")
root.title("测试")
app = Application(root)
root.mainloop()用来打包的文件
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(["test.py"],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name="test",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None )效果展示
到此这篇关于基于Python编写简易文字语音转换器的文章就介绍到这了,更多相关Python文字语音转换内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
X 关闭
X 关闭
- 15G资费不大降!三大运营商谁提供的5G网速最快?中国信通院给出答案
- 2联想拯救者Y70发布最新预告:售价2970元起 迄今最便宜的骁龙8+旗舰
- 3亚马逊开始大规模推广掌纹支付技术 顾客可使用“挥手付”结账
- 4现代和起亚上半年出口20万辆新能源汽车同比增长30.6%
- 5如何让居民5分钟使用到各种设施?沙特“线性城市”来了
- 6AMD实现连续8个季度的增长 季度营收首次突破60亿美元利润更是翻倍
- 7转转集团发布2022年二季度手机行情报告:二手市场“飘香”
- 8充电宝100Wh等于多少毫安?铁路旅客禁止、限制携带和托运物品目录
- 9好消息!京东与腾讯续签三年战略合作协议 加强技术创新与供应链服务
- 10名创优品拟通过香港IPO全球发售4100万股 全球发售所得款项有什么用处?

