OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

fetching upload file on flask and uploading it on my deepgram AI

  • Thread starter Thread starter daphney thokoana
  • Start date Start date
D

daphney thokoana

Guest
How to I get my uploaded file from flask to my AI

from deepgram import Deepgram import asyncio, json, os from flask import Flask, render_template, request, redirect

dg_key = '6a5db8f6e43c35769ddce7a3523c792179b69f5c' dg = Deepgram(dg_key)

MIMETYPE = 'mp3, wav'

DIRECTORY = 'UPLOAD_FOLDER'

options = { "punctuate": True, "diarize": True, "model": 'general', "tier": 'nova' }

def main(): audio_folder = os.listdir(DIRECTORY) for audio_file in audio_folder: if audio_file.endswith(MIMETYPE): with open(f"{DIRECTORY}/{audio_file}", "rb") as f: source = {"buffer": f, "mimetype":'audio/'+MIMETYPE} res = dg.transcription.sync_prerecorded(source, options) with open(f"./{audio_file[:-4]}.json", "w") as transcript: json.dump(res, transcript, indent=4) return

main()

file variable on my flack code and setting as my root on my ai code
<p>How to I get my uploaded file from flask to my AI</p>
<p>from deepgram import Deepgram
import asyncio, json, os
from flask import Flask, render_template, request, redirect</p>
<p>dg_key = '6a5db8f6e43c35769ddce7a3523c792179b69f5c'
dg = Deepgram(dg_key)</p>
<p>MIMETYPE = 'mp3, wav'</p>
<p>DIRECTORY = 'UPLOAD_FOLDER'</p>
<p>options = {
"punctuate": True,
"diarize": True,
"model": 'general',
"tier": 'nova'
}</p>
<p>def main():
audio_folder = os.listdir(DIRECTORY)
for audio_file in audio_folder:
if audio_file.endswith(MIMETYPE):
with open(f"{DIRECTORY}/{audio_file}", "rb") as f:
source = {"buffer": f, "mimetype":'audio/'+MIMETYPE}
res = dg.transcription.sync_prerecorded(source, options)
with open(f"./{audio_file[:-4]}.json", "w") as transcript:
json.dump(res, transcript, indent=4)
return</p>
<p>main()</p>
<p>file variable on my flack code and setting as my root on my ai code</p>
 

Latest posts

H
Replies
0
Views
1
Hür Doğan ÜNLÜ
H
Top