2016-01-26 18 views
6

我試圖使用pyvona但在說()函數這不斷髮生。下面是代碼:我的pyvona說()函數不工作

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 

,誤差

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

您正在使用什麼版本的pygame的嗎? – unutbu

+0

適合我,你是怎麼安裝pygame和pyvona的? –

+0

即時通訊使用pygame 1.9.2 –

回答

0

試試這個

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

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

如果該文件是一個聲音文件它壽ld工作。

0

後無法正常使用pygame的類似的問題,我搬到pyglet,嘗試:

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