muhammadnasar commited on
Commit
a792f20
1 Parent(s): 0530cc9

Create whisper.py

Browse files
Files changed (1) hide show
  1. whisper.py +18 -0
whisper.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def dowload_youtube_video(url):
2
+ from pytube import YouTube
3
+ yt = YouTube(url)
4
+ global audio_stream
5
+ audio_stream = yt.streams.filter(only_audio=True, file_extension='mp4').first()
6
+ audio_stream.download()
7
+ return 'download successfully'
8
+
9
+
10
+ def transcribe_audio():
11
+ import openai
12
+ from openai import OpenAI
13
+ import os
14
+ client = OpenAI(api_key=os.environ['openai_api_key'])
15
+ file = open(audio_stream.default_filename, "rb")
16
+ transcription = client.audio.transcriptions.create(model="whisper-1", file=file, response_format='text', language='ur')
17
+
18
+ return transcription