Next.JS: is it possible to use fetch to send a local audio .mp3 file (instead of a url) to DeepGram for a transcription? #410
-
|
Hi, I've been successful to get a transcription using Next.JS and fetch - but it only works by giving it the url to an audio file on the web. Generally it's a Next.JS (version 13.5.6) await fetch version of the curl method at the Deepgram API Playground: https://playground.deepgram.com/?smart_format=true&language=en&model=nova-2-ea But, wondering if these are possible:
Your help is much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hope this helps! |
Beta Was this translation helpful? Give feedback.
You can indeed! However, our API doesn't currently support custom CORS origins. We have a new JavaScript SDK being minted to beta tomorrow (so you can try the alpha now) which will work in a client component on Next.js.
In the readme for this version you'll find an explanation on the proxy support. You'll need a server component that can proxy the request to Deepgram. Any REST endpoints are subject to CORS restrictions. Effectively, you need to proxy the request to api.deepgram.com and return the results - you can also use this proxy to overwrite the Authorization header with the Deepgram API key, to prevent it from being exposed to the browser. I hope to build a demo of this proxy soon…