N. *_*our 6 python pygame function typeerror python-3.x
我正在尝试使用pyvona但是在speak()函数中这种情况一直在发生.这是代码:
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
Run Code Online (Sandbox Code Playgroud)
而错误是
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)
Run Code Online (Sandbox Code Playgroud)
小智 0
尝试这个
sound = pygame.mixer.Sound(file=f)
Run Code Online (Sandbox Code Playgroud)
或者
sound = pygame.mixer.Sound(file=f._file)
Run Code Online (Sandbox Code Playgroud)
如果该文件是声音文件,它应该可以工作。
归档时间: |
|
查看次数: |
471 次 |
最近记录: |