Example Code Error
Closed this issue · 2 comments
starbuck100 commented
Describe the bug
After running the Example code on local installation I receive following error:
Traceback (most recent call last):
File "C:\Users\mento\Documents\PyCharm\venv\lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\mento\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\mento\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\mento\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\mento\Documents\PyCharm\suno_wrapper\test.py", line 38, in <module>
data = generate_audio_by_prompt({
File "C:\Users\mento\Documents\PyCharm\suno_wrapper\test.py", line 22, in generate_audio_by_prompt
return response.json()
File "C:\Users\mento\Documents\PyCharm\venv\lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
To Reproduce
Steps to reproduce the behavior:
- Go to 'Clone Repository '
- Install packages in repo direcotry 'npm install'
- Copy Suno.ai cookie from header after visiting suno ai logged in.
- Start the server via npm run dev
- Run the Example Code [provided at the bottom]
Checking Suno Limit via firefox:
After fresh installation, when I visist 'http://localhost:3000/api/get_limit'.
I receive following error:
error | 'Internal server error. TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Cookie"]'
I already got it running once, but not anymore. I checked the cookie various times.
Desktop (please complete the following information):
- OS: Win10
- Browser [Firefox]
Additional context
Server error:
> suno-api@1.1.0 dev
> next dev
▲ Next.js 14.1.4
- Local: http://localhost:3000
- Environments: .env
Der Befehl "pnpm" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
✓ Ready in 1809ms
○ Compiling /api/generate ...
✓ Compiled /api/generate in 997ms (211 modules)
(node:10560) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
⨯ TypeError: Cannot read properties of undefined (reading 'data')
at POST (webpack-internal:///(rsc)/./src/app/api/generate/route.ts:39:91)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:63809
at async eU.execute (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:53964)
at async eU.handle (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:65062)
at async doRender (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:1317:42)
at async cacheEntry.responseCache.get.routeKind (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:1539:28)
at async DevServer.renderToResponseWithComponentsImpl (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:1447:28)
at async DevServer.renderPageComponent (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:1844:24)
at async DevServer.renderToResponseImpl (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:1882:32)
at async DevServer.pipeImpl (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:895:25)
at async NextNodeServer.handleCatchallRenderRequest (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\next-server.js:269:17)
at async DevServer.handleRequestImpl (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\base-server.js:791:17)
at async C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\dev\next-dev-server.js:331:20
at async Span.traceAsyncFn (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\trace\trace.js:151:20)
at async DevServer.handleRequest (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\dev\next-dev-server.js:328:24)
at async invokeRender (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\lib\router-server.js:174:21)
at async handleRequest (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\lib\router-server.js:353:24)
at async requestHandlerImpl (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\lib\router-server.js:377:13)
at async Server.requestListener (C:\Users\mento\Documents\PyCharm\suno_wrapper\suno-api-main\node_modules\next\dist\server\lib\start-server.js:140:13)
Example Code:
import time
import requests
# replace your vercel domain
base_url = 'http://localhost:3000'
def custom_generate_audio(payload):
url = f"{base_url}/api/custom_generate"
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
return response.json()
def extend_audio(payload):
url = f"{base_url}/api/extend_audio"
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
return response.json()
def generate_audio_by_prompt(payload):
url = f"{base_url}/api/generate"
response = requests.post(url, json=payload, headers={'Content-Type': 'application/json'})
return response.json()
def get_audio_information(audio_ids):
url = f"{base_url}/api/get?ids={audio_ids}"
response = requests.get(url)
return response.json()
def get_quota_information():
url = f"{base_url}/api/get_limit"
response = requests.get(url)
return response.json()
if __name__ == '__main__':
data = generate_audio_by_prompt({
"prompt": "A popular heavy metal song about war, sung by a deep-voiced male singer, slowly and melodiously. The lyrics depict the sorrow of people after the war.",
"make_instrumental": False,
"wait_audio": False
})
ids = f"{data[0]['id']},{data[1]['id']}"
print(f"ids: {ids}")
for _ in range(60):
data = get_audio_information(ids)
if data[0]["status"] == 'streaming':
print(f"{data[0]['id']} ==> {data[0]['audio_url']}")
print(f"{data[1]['id']} ==> {data[1]['audio_url']}")
break
# sleep 5s
time.sleep(5)
Additional Info:
NPM-Version
: 10.5.0
Node-Version
: v21.7.3
blueeon commented
@GitPusher99 pls give a hand
starbuck100 commented
Hi guys, it seems that my .env file was corrupted.
Now it works again.
Thanks and sorry for the inconvenience!