Dhruv12121 commited on
Commit
e00da4e
·
1 Parent(s): 4b1d890

Fix : added the main.py file

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. Readme.md +17 -0
  3. main.py +54 -0
  4. requirements.txt +6 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
Readme.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Steps to reproduce the repo
2
+
3
+ ## Start with Python 3.11.8 new environment or use conda to create new env with python 3.11.8
4
+
5
+ ## Commands to start with Conda
6
+
7
+ ## conda create -n AudioAnalyze python=3.11.8
8
+
9
+ ## Command to activate conda env
10
+
11
+ ## conda activate AudioAnalyze
12
+
13
+ ## Install requirements using pip
14
+
15
+ ## pip install -r requirements.txt
16
+
17
+ ## Run main.py file
main.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import os
4
+ from dotenv import load_dotenv
5
+
6
+ from deepgram import (
7
+ DeepgramClient,
8
+ PrerecordedOptions,
9
+ FileSource,
10
+ )
11
+
12
+ load_dotenv()
13
+
14
+ API_KEY = os.getenv("DEEPGRAM_KEY")
15
+
16
+ def process_mp3(file_info):
17
+ try:
18
+ deepgram = DeepgramClient(API_KEY)
19
+
20
+ with open(file_info, "rb") as file:
21
+ buffer_data = file.read()
22
+
23
+ payload: FileSource = {
24
+ "buffer": buffer_data,
25
+ }
26
+
27
+ options = PrerecordedOptions(
28
+ model="base",
29
+ diarize = True,
30
+ smart_format=True
31
+ )
32
+
33
+ response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options)
34
+
35
+ except Exception as e:
36
+ print(f"Exception: {e}")
37
+
38
+ return response.results.channels[0].alternatives[0].paragraphs.transcript
39
+
40
+ def main():
41
+ # Define the Gradio interface
42
+ iface = gr.Interface(
43
+ fn=process_mp3,
44
+ inputs=gr.File(label="Upload MP3 File", file_types=["mp3"]),
45
+ outputs="text",
46
+ title="MP3 File Uploader",
47
+ description="Upload an MP3 file to process."
48
+ )
49
+
50
+ # Launch the interface
51
+ iface.launch()
52
+
53
+ if __name__ == "__main__":
54
+ main()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio
2
+ deepgram-sdk
3
+ python-dotenv
4
+ langchain-google-genai
5
+ langchain
6
+