【问题标题】:Is there a Premium Account necesary for the Spotify API?Spotify API 是否需要高级帐户?
【发布时间】:2021-02-28 17:23:51
【问题描述】:

我正在尝试对音量进行 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()

【问题讨论】:

    标签: python spotify spotipy


    【解决方案1】:

    是的,该 API 调用需要高级帐户。根据the docs:

    如果发出请求的用户是非高级用户,将返回 403 FORBIDDEN 响应码。

    【讨论】:

    • 为什么需要高级版,它只是音量?
    • 我不知道,问 Spotify。也许想要在 Spotify 生态系统中开发自己的应用程序的人也会付钱给他们?
    猜你喜欢
    • 1970-01-01
    • 2019-10-27
    • 2017-08-20
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 2023-02-04
    • 2023-03-04
    相关资源
    最近更新 更多