小编Lic*_*ing的帖子

如何从URL播放mp3

我正在尝试编写一个将从Soundcloud URL播放mp3的python脚本

这就是我已经做过的事情:

from urllib.request import urlopen

url = "soundcloud.com/artist/song.mp3"
u = urlopen(url)

data = u.read(1024)

while data:
   player.play(data)
   data = u.read(1024)
Run Code Online (Sandbox Code Playgroud)

我试过pyaudio很多选项,比如改变格式,频道,速率.我只是从扬声器发出奇怪的声音,我搜索谷歌pyaudio播放MP3并没有找到任何信息.

我尝试pygame通过Sound从mp3传递字节然后只是通过执行播放功能来创建对象.我没有收到任何错误:脚本运行但没有播放.

我正在使用Python 3和Ubuntu.

python audio ubuntu

5
推荐指数
1
解决办法
1万
查看次数

谷歌云语音api在尝试使用时抛出403

我在谷歌云语音api上使用python我在ubuntu和Windows上的" 如何在python中使用谷歌语音识别api "中执行了所有步骤,当我尝试从这里运行简单脚本时 - " https: //github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/api/speech_rest.py "

我收到下一个错误: <HttpError 403 when requesting https://speech.googleapis.com/$discovery/rest?version=v1beta1 returned "Google Cloud Speech API has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">

奇怪的是,我没有名为"cloudsdktool"的项目

我运行"gcloud init",并将我在创建服务帐户密钥时获得的json文件与"gcloud auth activate-service-account --key-file = jsonfile"命令相关联,我在linux中尝试创建google凭据环境变量我仍然得到同样的按摩

python linux google-speech-api

5
推荐指数
1
解决办法
1364
查看次数

标签 统计

python ×2

audio ×1

google-speech-api ×1

linux ×1

ubuntu ×1