-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathspeakwithchatGPT.py
56 lines (46 loc) · 1.47 KB
/
speakwithchatGPT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import whisper
import sounddevice as sd
from scipy.io.wavfile import write
import os
import tempfile
import queue
import sys
from testgpt import chatme
import sounddevice as sd
import soundfile as sf
import numpy
assert numpy
from audiorecording import rec_audio
class whisper_gpt:
def __init__(self,model_size,file) :
self.model_size=model_size
self.file=file
self.model = whisper.load_model(model_size)
def transcribe(self):
self.final = self.model.transcribe(self.file)
def get_result(self):
self.transription=self.final["text"]
return self.transription
choice = input("Enter your medium to chat with chatGPT \n 1: Chat with Voice \n 2: Chat with saved audio clip \n 3: Chat with text \n ")
if choice == "1":
decision=True
while decision==True:
audiofile=rec_audio("test")
whispers = whisper_gpt("base",audiofile)
whispers.transcribe()
output=whispers.get_result()
final_out=chatme(output)
takeusr=input("Continue..... Y/N")
if takeusr=="y":
decision=True
else:
print("Nice Talking to you !!")
decision=False
elif choice =="2":
print("You gotta select the first option!!!!")
whispers = whisper_gpt("base","testy4pzkg2r.wav")
whispers.transcribe()
whispers.get_result()
elif choice =="3":
input_text=input("Enter the text... \n ")
final_out=chatme(input_text)