elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Curso de javascript por TickTack


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  TTS en Python [Loquendo Pythoniano xD]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: TTS en Python [Loquendo Pythoniano xD]  (Leído 6,736 veces)
invisible_hack


Desconectado Desconectado

Mensajes: 978


Invisible_Hack™ Nick Registrado ^^


Ver Perfil WWW
TTS en Python [Loquendo Pythoniano xD]
« en: 25 Junio 2010, 18:06 pm »

Código
  1. # Text To Speech using SAPI (Windows) and Python module pyTTS by Peter Parente
  2. # download installer file pyTTS-3.0.win32-py2.4.exe  
  3. # from:  http://sourceforge.net/projects/uncassist
  4. # also needs: http://www.cs.unc.edu/Research/assist/packages/SAPI5SpeechInstaller.msi
  5. # and pywin32-204.win32-py2.4.exe at this date the latest version of win32com
  6. # from: http://sourceforge.net/projects/pywin32/
  7. # tested with Python24 on a Windows XP computer   vagaseat   15jun2005
  8.  
  9. import pyTTS
  10. import time
  11.  
  12. tts = pyTTS.Create()
  13.  
  14. # set the speech rate, higher value = faster
  15. # just for fun try values of -10 to 10
  16. tts.Rate = 1
  17. print "Speech rate =", tts.Rate
  18.  
  19. # set the speech volume percentage (0-100%)
  20. tts.Volume = 90
  21. print "Speech volume =", tts.Volume
  22.  
  23. # get a list of all the available voices
  24. print "List of voices =", tts.GetVoiceNames()
  25.  
  26. # explicitly set a voice
  27. tts.SetVoiceByName('MSMary')
  28. print "Voice is set ot MSMary"
  29.  
  30. print
  31.  
  32. # announce the date and time, does a good job
  33. timeStr = "The date and time is " + time.asctime()
  34. print timeStr
  35. tts.Speak(timeStr)
  36.  
  37. print
  38.  
  39. str1 = """
  40. A young executive was leaving the office at 6 pm when he found
  41. the CEO standing in front of a shredder with a piece of paper in hand.
  42.  
  43. "Listen," said the CEO, "this is important, and my secretary has left.
  44. Can you make this thing work?"
  45.  
  46. "Certainly," said the young executive. He turned the machine on,
  47. inserted the paper, and pressed the start button.
  48.  
  49. "Excellent, excellent!" said the CEO as his paper disappeared inside
  50. the machine. "I just need one copy."
  51. """
  52. print str1
  53. tts.Speak(str1)
  54. tts.Speak('Haah haa haah haa')
  55.  
  56. print
  57.  
  58. str2 = """
  59. Finagle's fourth law:
  60.  Once a job is fouled up, anything done to improve it only makes it worse.
  61. """
  62. print str2
  63. print
  64. print "The spoken text above has been written to a wave file (.wav)"
  65. tts.SpeakToWave('Finagle4.wav', str2)
  66.  
  67. print "The wave file is loaded back and spoken ..."
  68. tts.SpeakFromWave('Finagle4.wav')
  69.  
  70. print
  71.  
  72. print "Substitute a hard to pronounce word like Ctrl key ..."
  73. #create an instance of the pronunciation corrector
  74. p = pyTTS.Pronounce()
  75. # replace words that are hard to pronounce with something that
  76. # is spelled out or misspelled, but at least sounds like it
  77. p.AddMisspelled('Ctrl', 'Control')
  78. str3 = p.Correct('Please press the Ctrl key!')
  79. tts.Speak(str3)
  80.  
  81. print
  82.  
  83. print "2 * 3 = 6"
  84. tts.Speak('2 * 3 = 6')
  85.  
  86. print
  87.  
  88. tts.Speak("sounds goofy, let's replace * with times")
  89. print "Substitute * with times"
  90. # ' * ' needs the spaces
  91. p.AddMisspelled(' * ', 'times')
  92. str4 = p.Correct('2 * 3 = 6')
  93. tts.Speak(str4)
  94.  
  95. print
  96.  
  97. print "Say that real fast a few times!"
  98. str5 = "The sinking steamer sunk!"
  99. tts.Rate = 3
  100. for k in range(7):
  101.    print str5
  102.    tts.Speak(str5)
  103.    time.sleep(0.3)
  104.  
  105. tts.Rate = 0
  106. tts.Speak("Wow, not one mispronounced word!")
  107.  


Pues hace tiempo hice un programilla en VB que reproducía el texto que le introdujeras por voz...y como ahora estoy empezando a meterme cada vez más en Python, me dio la curiosidad de si se podría hacer esto mismo en este lenguaje, y, así es, cada vez veo que hay menos cosas imposibles en Python, de lo cual me alegro   ;D

Hay que descargarse el módulo llamado pyTTS, desarrollado por un tal Peter Parente.

Recordemos que estos ejemplos de TTS usan las voces que trae Windows para muestra de voces, osea de habla inglesa...

No he probado aún este ejemplo, pero por los comentarios parece ser que funciona bien...

Os dejo el link de donde saqué el código, porque yo no soy su autor...

http://www.daniweb.com/code/snippet216573.html

Un saludo.   :D


En línea

"Si no visitas mi blog, Chuck te dará una patada giratoria"
Debci
Wiki

Desconectado Desconectado

Mensajes: 2.021


Actualizate o muere!


Ver Perfil WWW
Re: TTS en Python [Loquendo Pythoniano xD]
« Respuesta #1 en: 25 Junio 2010, 21:01 pm »

Muy bueno pero por ejemplo yo no se ni como se añaden librerias a python que soy nuevillo en este lang.

Saludos


En línea

leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: TTS en Python [Loquendo Pythoniano xD]
« Respuesta #2 en: 25 Junio 2010, 22:11 pm »

Lo referente a python va en la sección de scripting.
En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Instalar voz de Ximena-Loquendo y usarla en tu programa « 1 2 3 4 »
Programación General
Edu 30 58,514 Último mensaje 16 Junio 2019, 17:50 pm
por Machacador
Instalar Loquendo TTS 7 + Todas las voces
Software
metroid_300 0 1,743 Último mensaje 14 Abril 2013, 12:33 pm
por metroid_300
Problema con DirectSS y voces loquendo...
Programación Visual Basic
79137913 0 1,407 Último mensaje 13 Septiembre 2013, 17:19 pm
por 79137913
Como Hackear loquendo
Juegos y Consolas
Gaheru 0 2,240 Último mensaje 27 Abril 2014, 06:51 am
por Gaheru
duda voces loquendo
Dudas Generales
General Dmitry Vergadoski 0 2,357 Último mensaje 10 Septiembre 2021, 15:05 pm
por General Dmitry Vergadoski
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines