简体   繁体   English

kivy.core.audio 没有声音 output

[英]No sound output from kivy.core.audio

The problem I am having from kivy.core.audio is no sound output from my speakers (the speakers are fine).我从 kivy.core.audio 遇到的问题是我的扬声器没有声音 output (扬声器很好)。 The file format I am trying to play is an mp3.我要播放的文件格式是 mp3。 I have copied the code from the api documentation from the official kivy website but it just wont output any sound.我已经从官方 kivy 网站复制了 api 文档中的代码,但它只是不会 output 任何声音。 The file is being accepted into an object as you will see in the output but no sound comes out.正如您将在 output 中看到的那样,该文件正在被 object 接受,但没有声音出现。

# hungarian_tutor.py

''' A program to teach Hungarian translated from English '''
import kivy
kivy.require("1.11.1")

from kivy.core.audio import SoundLoader
from random import choice

alphabet = ("a", "á", "b", "c", "cs", "d", "dz", "dzs", "e", "é", "f", "g", "gy", "h", "i", "í", "j", "k", "l", "ly",
             "m", "n", "ny", "o", "ó", "ö", "ő", "p", "q", "r", "s", "sz", "t", "ty", "u", "ú", "ü", "ű", "v", "w", "x",
             "y", "z", "zs")

basic_phrases = [["Hello", "Szia", "hello.mp3"],["Good Morning", "Translate*", "good-morning.mp3"]]

phrase = choice(basic_phrases)
eng = phrase[0]; hun = phrase[1]; hun_audio = phrase[2]
audio = SoundLoader.load("audio/" + hun_audio)
if audio:
    audio.play()

Output: Output:

 C:\Users\jhowd\PycharmProjects\hungarian_tutor\venv\Scripts\python.exe C:/Users/jhowd/PycharmProjects/hungarian_tutor/hungarian_tutor.py
[INFO   ] [Logger      ] Record log in C:\Users\jhowd\.kivy\logs\kivy_20-05-14_27.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.1.18
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.1.10
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.1.12
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.1.23
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\jhowd\PycharmProjects\hungarian_tutor\venv\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\jhowd\PycharmProjects\hungarian_tutor\venv\Scripts\python.exe"
[INFO   ] [AudioGstplayer] Using Gstreamer 1.16.0.0
[INFO   ] [Audio       ] Providers: audio_gstplayer, audio_sdl2 (audio_ffpyplayer ignored)
[WARNING] Deprecated property "<AliasProperty name=filename>" of object "<kivy.core.audio.audio_gstplayer.SoundGstplayer object at 0x000002BF6A5722B8>" was accessed, it will be removed in a future version

Process finished with exit code 0

audio.play() immediately returns after starts the sound. audio.play()在启动声音后立即返回。

Put import time;time.sleep(audio.length) to the end of the file.import time;time.sleep(audio.length)放在文件末尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM