我正在写一个python脚本扫描包含文本的照片与谷歌视觉光学字符识别,然后使用谷歌gTTS说出文本。代码如下:
#BookrBasic
from os import system
from time import sleep
from pygame import mixer
from gtts import gTTS
import subprocess
def tts(speech):
tts = gTTS(text=speech, lang='en')
tts.save("/tmp/text.mp3")
subprocess.Popen(['mp
我正在尝试使用谷歌的text- to -speech应用编程接口读取.txt文件。但是,当我尝试运行它时,它给出了一个我无法完全理解的错误。因此,我们将非常感谢您的帮助! 我的Python代码: #Import the required module for text
from gtts import gTTS
#required to play the converted file
import os
#The file you want to convert
with open('/Users/humma/Desktop/python_projects/flowers
我正在使用一个使用python和discord.py的discord机器人。我在discord上启用了TTS,甚至当我使用标记tts=False时,只要我让机器人向通道发送消息,它就会使用tts读出消息。我不知道如何禁用它,因为文档中只简单地说要使用tts=False,这就是我正在做的。因此,在下面的示例中,当输入.ping时,tts读出"Bot says My ping is 10ms“,并向通道发送相同的消息,我希望它只向通道发送消息,而不是读出它。 import discord
from discord.ext import commands
client = command
所以我找到了这段代码:
#!/usr/bin/python
import sys #for cmd line argv
import time #for delay
import pygst #for playing mp3 stream
import gst # " "
#take command line args as the input string
input_string = sys.argv
#remove the program name from the argv list
input_string.pop(0)
我想使用pyttsx3脱机将文本转换为语音,并将输出保存为音频文件。 我已经看到了this问题,第一个答案就是我需要的。我就是不能让它正常工作。 运行此命令时: import pyttsx3
tts = pyttsx3.init()
tts.setProperty('voice', tts.getProperty('voice')[1])
tts.save_to_file("What an amazing day today! I'm gonna go for a swim.", "./filename.mp3")
tt
我构建了一个简单的应用程序来识别语音并说出结果。但是,当我通过Buildozer从python文件中创建APK时,tts可以工作,但stt,即语音识别不能工作。我在这里使用的和TTS库是
代码如下:
import kivy
from kivy.app import App
from kivy.uix.switch import Switch
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.image import Image
class Switch
当音频文件与播放声音模块停止时,我可以删除它吗?我写了一段代码,但我做不到:
from gtts import gTTS
import os
import playsound
def say(textg):
tts = gTTS(text=textg, lang='en')
tts.save('audio.mp3')
playsound('audio.mp3')
time.sleep(here, what i have to do?)
os.remove('audio.mp3')
我正在使
我正在尝试使用以下URL从文本生成语音消息:
"http://translate.google.com/translate_tts?tl=es&q=La+castaña+está+muy+buena"
使用python,但urllib库失败,出现以下错误:
File "/usr/lib/python2.7/urllib.py", line 227, in retrieve
url = unwrap(toBytes(url))
File "/usr/lib/python2.7/urllib.py", line 1051, i
我已经成功地在我的机器上安装了gTTS (Google text-to-speech)库,并运行了以下简单的代码: from gtts import gTTS
tts = gTTS('hello') 但是我得到了这个错误: "/usr/local/lib/python3.7/dist-packages/gtts/tts.py", line 114, in __init__
for k, v in locals().items():
RuntimeError: dictionary changed size during iteration. 我做错了
from gtts import gTTS
import os
import subprocess
tts = gTTS(text='Hello World', lang='en') //TEXT TO SPEECH
tts.save("audio.mp3") //Hello world will be saved in audio.mp3
os.system("mpg321 audio.mp3") <-- I want to play the audio file in python(not to call any oth
我正在比较下面程序中的两个文件。如果相同,则我将打印为成功,否则打印为失败。我正在使用一个叫jenkins的集成工具,当比较文件失败时发送一封电子邮件,为了做到这一点-我必须正确处理错误。有人能告诉我如何处理这个错误吗?
Error_Status=0
def compare_files(file1, file2):
try:
with open(file1, 'rb') as f_file1, open(file2, 'rb') as f_file2:
if f_file1.read() == f_file2.read(
我试图让它保存一个.wav文件,上面写着“早上好”。它这样做,等待两秒钟,然后播放一个窗口的声音。我使用Python3.7.2并在Windows 10上操作。
from gtts import gTTS
import winsound
import time
tts = gTTS(text='Good morning', lang='en')
tts.save("good.wav")
time.sleep(2)
#it works until here
winsound.PlaySound("good", winsound.SN