Samarth991 commited on
Commit
99b2550
1 Parent(s): 34a0eeb

adding duration feature

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -14,6 +14,7 @@ FILE_EXT = ['wav','mp3']
14
  MAX_NEW_TOKENS = 4096
15
  DEFAULT_MAX_NEW_TOKENS = 1024
16
  DEFAULT_TEMPERATURE = 0.1
 
17
 
18
  def create_logger():
19
  formatter = logging.Formatter('%(asctime)s:%(levelname)s:- %(message)s')
@@ -55,6 +56,7 @@ def process_documents(documents,data_chunk=1500,chunk_overlap=100):
55
  def audio_processor(wav_file,API_key,wav_model='small',llm='HuggingFace',temperature=0.1,max_tokens=4096,duration=5):
56
  device='cpu'
57
  logger.info("Audio File Name :",wav_file.name)
 
58
  whisper = whisper_app.WHISPERModel(model_name=wav_model,device=device)
59
  logger.info("Whisper Model Loaded || Model size:{}".format(wav_model))
60
  text_info = whisper.speech_to_text(audio_path=wav_file.name)
@@ -67,6 +69,7 @@ def audio_processor(wav_file,API_key,wav_model='small',llm='HuggingFace',tempera
67
 
68
  embedding_model = SentenceTransformerEmbeddings(model_name='thenlper/gte-large',model_kwargs={"device": device})
69
  texts = process_documents(documents=document)
 
70
  global vector_db
71
  vector_db = FAISS.from_documents(documents=texts, embedding= embedding_model)
72
  global qa
@@ -82,7 +85,6 @@ def audio_processor(wav_file,API_key,wav_model='small',llm='HuggingFace',tempera
82
  chat = llm_ops.get_openai_chat_model(API_key=API_key)
83
 
84
  chain_type_kwargs = {"prompt": create_prompt()}
85
-
86
  qa = RetrievalQA.from_chain_type(llm=chat,
87
  chain_type='stuff',
88
  retriever=vector_db.as_retriever(),
@@ -165,6 +167,7 @@ with gr.Blocks(css=css) as demo:
165
  step=1,
166
  value=DEFAULT_MAX_NEW_TOKENS,
167
  )
 
168
  temperature = gr.Slider(
169
  label='Temperature',
170
  minimum=0.1,
 
14
  MAX_NEW_TOKENS = 4096
15
  DEFAULT_MAX_NEW_TOKENS = 1024
16
  DEFAULT_TEMPERATURE = 0.1
17
+ DEFAULT_DURATION = 5
18
 
19
  def create_logger():
20
  formatter = logging.Formatter('%(asctime)s:%(levelname)s:- %(message)s')
 
56
  def audio_processor(wav_file,API_key,wav_model='small',llm='HuggingFace',temperature=0.1,max_tokens=4096,duration=5):
57
  device='cpu'
58
  logger.info("Audio File Name :",wav_file.name)
59
+
60
  whisper = whisper_app.WHISPERModel(model_name=wav_model,device=device)
61
  logger.info("Whisper Model Loaded || Model size:{}".format(wav_model))
62
  text_info = whisper.speech_to_text(audio_path=wav_file.name)
 
69
 
70
  embedding_model = SentenceTransformerEmbeddings(model_name='thenlper/gte-large',model_kwargs={"device": device})
71
  texts = process_documents(documents=document)
72
+
73
  global vector_db
74
  vector_db = FAISS.from_documents(documents=texts, embedding= embedding_model)
75
  global qa
 
85
  chat = llm_ops.get_openai_chat_model(API_key=API_key)
86
 
87
  chain_type_kwargs = {"prompt": create_prompt()}
 
88
  qa = RetrievalQA.from_chain_type(llm=chat,
89
  chain_type='stuff',
90
  retriever=vector_db.as_retriever(),
 
167
  step=1,
168
  value=DEFAULT_MAX_NEW_TOKENS,
169
  )
170
+ duration = gr.slider(label='duration in min',minimum=5,maximum = 10,step=1,value=DEFAULT_DURATION)
171
  temperature = gr.Slider(
172
  label='Temperature',
173
  minimum=0.1,