我正在试着做一个Spotify的音量控制,但我似乎想不通了。有什么想法吗?我已经被困在这个问题上有一段时间了,上面写着Player command failed: Premium required, reason: PREMIUM_REQUIRED
。任何帮助都将不胜感激
import spotipy
from spotipy.oauth2 import SpotifyOAuth
import speech_recognition as sr
import pyttsx3
auth_manager = SpotifyOAuth(
client_id="myclientid",
client_secret="myclientsecret",
redirect_uri="http://localhost:8888/callback",
username="username",
scope="user-modify-playback-state"
)
spotipy = spotipy.Spotify(auth_manager=auth_manager)
engine = pyttsx3.init()
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Listening...')
r.pause_threshold = 0.5
r.energy_threshold = 494
r.adjust_for_ambient_noise(source, duration=0.3)
audio = r.listen(source)
try:
print('Recognizing..')
query = r.recognize_google(audio, language='en-us')
print(f'User said: {query}\n')
except Exception as e:
# print(e)
print('Say that again please...')
return 'None'
return query
def LowerVolume():
spotipy.volume(15)
while True:
query = takeCommand().lower()
if "lower volume" in query:
LowerVolume()
发布于 2021-03-01 01:27:26
是的,该API调用需要Premium帐户。根据the docs
如果发出请求的用户是非高级用户,则将返回403禁止响应代码。
https://stackoverflow.com/questions/66411861
复制相似问题