2016-01-26 32 views
6

Tôi đang cố gắng sử dụng pyvona nhưng trong hàm speak() điều này vẫn tiếp diễn. Đây là mã:Chức năng pyvona speak() của tôi không hoạt động

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 

và lỗi là

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

Phiên bản nào của pygame bạn đang sử dụng? – unutbu

+0

hoạt động tốt cho tôi, làm thế nào bạn cài đặt pygame và pyvona? –

+0

im sử dụng pygame 1.9.2 –

Trả lời

0

Hãy thử điều này

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

hoặc

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

Nếu tập tin là một tập tin âm thanh nó shou ld làm việc.

0

Sau khi có vấn đề tương tự với pygame, tôi chuyển đến pyglet, hãy thử:

Import pyglet 
music = pyglet.media.load('file.mp3') 
music.play() 
pyglet.app.run() 
Các vấn đề liên quan