gcui-art / suno-api

Use API to call the music generation AI of suno.ai, and easily integrate it into agents like GPTs.
https://suno.gcui.ai
GNU Lesser General Public License v3.0
1.43k stars 329 forks source link

"make_instrumental" set to false, still returns `lyric`: [instrumental] #140

Closed yeetmaster69 closed 4 months ago

yeetmaster69 commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: Try submitting a request to api/generate with make_instrumental set to false. Mine still returns an instrumental with no lyrics.

Expected behavior Setting the make_instrumental to false should return a song with lyrics

Screenshots

Screenshot 2024-07-22 at 12 02 36 PM

I have content-type set to application/json Here is my code (it's in Swift):

func generateSunoAPI(prompt: String, completion: @escaping (_ response: Array<SunoAPIAudioResponse>?, _ error: Error?) -> Void) {
        let body: [String: Any] = ["prompt": "\(prompt)", "make_instrumental": "false", "wait_audio": "true"]
        let bodyData = try? JSONSerialization.data(withJSONObject: body)
        Task {
            do {
                var request = URLRequest(url: endpointUrl!)
                request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
                request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Accept")
                request.httpMethod = "POST"
                request.timeoutInterval = 120
                request.httpBody = bodyData

                let (data, response) = try await URLSession.shared.data(for: request)

                guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else {
                    completion(nil, NetworkError.badStatus)
                    return
                }

                let responseData = try JSONDecoder().decode(Array<SunoAPIAudioResponse>.self, from: data)
                print("SUNO GENERATE RESPONSE DATA")
                print(responseData)
                completion(responseData, nil)
            } catch {
                print("There was an error generating suno API in generateSunoAPI")
                completion(nil, error)
            }
        }
    }
yeetmaster69 commented 4 months ago

make_instrumental false was a String not a Boolean