基于Python编写简易文字语音转换器
作者:Camile8 发布时间:2023-12-28 19:24:54
标签: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 )
效果展示
来源:https://blog.csdn.net/lipeitong333/article/details/123493376
0
投稿
猜你喜欢
- 下面通过文字说明和代码分析的方式给大家分享移动端图片上传之localResizeIMG先压缩后ajax无刷新上传,具体实现过程请看下文。现在
- 使用pyinstaller可以把.py文件打包为.exe可执行文件,命令为:pyinstaller hello.py打包后有两个文件夹,一个
- 对于值传递和引用传递,书本上的解释比较繁琐,而php面试中总会出现,下面我会通过一个生活的例子带大家理解它们之间区别。第一步假设我们去酒店订
- 1、获取元素 2、获取数据 3、绑定数据 4、隔行换色&
- 本文实例为大家分享了python实现五子棋小游戏的具体代码,供大家参考,具体内容如下暑假学了十几天python,然后用pygame模块写了一
- 写在前面ufunc是universal function的缩写,意思是这些函数能够作用于narray对象的每一个元素上,而不是针对narra
- 问题你想读写JSON(JavaScript Object Notation)编码格式的数据。解决方案json 模块提供了一种很简单的方式来编
- LDA(Latent Dirichlet allocation)模型是一种常用而用途广泛地概率主题模型。其实现一般通过Variational
- 本文实例讲述了Python使用sklearn实现的各种回归算法。分享给大家供大家参考,具体如下:使用sklearn做各种回归基本回归:线性、
- 前言:书终于完稿了,我也有了一些自己的时间,于是决定将书中讲到的一些比较常见的知识点整理出来,发在Blog里面。当然也不会完全发表出来,毕竟
- 背景最近在写一个echarts数据看板,要在一个页面中展示多张图表,所以留给每张图表的尺寸就很小。这也就使得图表x轴的刻度文字全部挤到一起了
- 找了半天,以为numpy的where函数像matlab 的find函数一样好用,能够返回一个区间内的元素索引位置。结果没有。。(也可能是我没
- 本文实例为大家分享了python实现名片管理系统的具体代码,供大家参考,具体内容如下功能需求用户输入数字选择要进行的操作添加名片删除名片修改
- 一、 技术要点 我们都知道Windows应用程序在运行时会启动一个进程,其总包括若干线程,不同的进程之间通信是开发分布
- js 闭包(closure)是Javascript语言的一个难点,也是它的特色。闭包的作用:通过一系方法,将函数内部的变量(局部变量)转化为
- 本文实例讲述了python中黄金分割法实现方法。分享给大家供大家参考。具体实现方法如下:''' a,b = brac
- 前言反爬虫是网站为了维护自己的核心安全而采取的抑制爬虫的手段,反爬虫的手段有很多种,一般情况下除了百度等网站,反扒机制会常常更新以外。为了保
- 以下均在本人虚拟机上进行1.安装pip3sudo apt install python3-pip2.安装虚拟环境sudo apt insta
- 本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用。 1.查看所有数据库容量大小select tab
- 随着ES6规范的到来,Js中定义变量的方法已经由单一的 var 方式发展到了 var、let、const 三种之多。var 众所周知,可那俩