栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

用python写文字语音转换器

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用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 )

效果展示

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/768024.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号