Texto a Voz usando SAPI
Viernes, 9 de Octubre de 2009 por jorgeHe estado jugando con las bibliotecas de texto a voz de windows.
Me ha sorprendido lo fácil que es hacer hablar al ordenador!! En principio solo hay una voz instalada. Puedes instalar otras voces pero he tenido poco éxito en conseguirlas ya que todas las que he encontrado son de pago. El siguiente paso es hacer un lector de correos y rss
De momento os dejo un par de líneas para .net y para python para ejecutar el sintetizador.
VB.NET
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim synth As SpeechSynthesizer = New SpeechSynthesizer()
synth.Speak("Hello, world!")
For Each voic As InstalledVoice In synth.GetInstalledVoices()
synth.SelectVoice(voic.VoiceInfo.Name)
synth.Speak(voic.VoiceInfo.Name)
Next
End Sub
Python (http://www.daniweb.com/code/snippet216573.html)
# Text To Speech using SAPI (Windows) and Python module pyTTS by Peter Parente
# download installer file pyTTS-3.0.win32-py2.4.exe
# from: http://sourceforge.net/projects/uncassist
# also needs: http://www.cs.unc.edu/Research/assist/packages/SAPI5SpeechInstaller.msi
# and pywin32-204.win32-py2.4.exe at this date the latest version of win32com
# from: http://sourceforge.net/projects/pywin32/
# tested with Python24 on a Windows XP computer vagaseat 15jun2005
import pyTTS
import time
tts = pyTTS.Create()
# set the speech rate, higher value = faster
# just for fun try values of -10 to 10
tts.Rate = 1
print "Speech rate =", tts.Rate
# set the speech volume percentage (0-100%)
tts.Volume = 90
print "Speech volume =", tts.Volume
# get a list of all the available voices
print "List of voices =", tts.GetVoiceNames()
# explicitly set a voice
tts.SetVoiceByName('MS-Anna-1033-20-DSK')
print "Voice is set ot MS-Anna-1033-20-DSK"


