2016-01-26 1 views
6

J'essaie d'utiliser pyvona mais dans la fonction speak() cela continue à se produire. Voici le code:ma fonction pyvona speak() ne fonctionne pas

def speak(self, text_to_speak): 
    """Speak a given text 
    """ 
    if not pygame_available: 
     raise PyvonaException(
      "Pygame not installed. Please install to use speech.") 

    with tempfile.SpooledTemporaryFile() as f: 
     with self.use_ogg_codec(): 
      self.fetch_voice_fp(text_to_speak, f) 
     f.seek(0) 
     if not pygame.mixer.get_init(): 
      pygame.mixer.init() 
     channel = pygame.mixer.Channel(5) 
     sound = pygame.mixer.Sound(f) 
     channel.play(sound) 
     while channel.get_busy(): 
      pass 

et l'erreur est

Traceback (most recent call last): 
    File "/Users/noahchalifour/Desktop/pyvona-0.25/pyvona.py", line 250, in <module> 
     v.speak('Hello World') 
    File "/Users/noahchalifour/Desktop/pyvona-0.25/pyvona.py", line 138, in speak 
     sound = pygame.mixer.Sound(f) 
TypeError: Unrecognized argument (type SpooledTemporaryFile) 
+0

Quelle version de pygame utilisez-vous? – unutbu

+0

fonctionne bien pour moi, comment avez-vous installé pygame et pyvona? –

+0

Im utilisant pygame 1.9.2 –

Répondre

0

Essayez cette

sound = pygame.mixer.Sound(file=f) 

ou

sound = pygame.mixer.Sound(file=f._file) 

Si le fichier est un fichier son il shou ld travail.

0

Après avoir des problèmes similaires avec pygame, je me suis déplacé à pyglet, essayez:

Import pyglet 
music = pyglet.media.load('file.mp3') 
music.play() 
pyglet.app.run()