Manuel Torres commited on
Commit
7d83056
·
1 Parent(s): 1f79b38

First commit

Browse files
Files changed (2) hide show
  1. app.py +52 -0
  2. requirements.txt +95 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import pipeline
3
+ import gradio as gr
4
+ import torch
5
+ import gradio as gr
6
+ from langchain_huggingface import ChatHuggingFace, HuggingFacePipeline
7
+ from transformers import AutoModelForCausalLM, AutoTokenizer
8
+ from langchain_core.messages import (
9
+ HumanMessage,
10
+ SystemMessage,
11
+ )
12
+
13
+ model_id = "meta-llama/Llama-3.2-1B-Instruct"
14
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
15
+ model = AutoModelForCausalLM.from_pretrained(model_id)
16
+ pipeLlama = pipeline("text-generation", model=model,
17
+ tokenizer=tokenizer, max_new_tokens=10)
18
+ hf = HuggingFacePipeline(pipeline=pipeLlama)
19
+
20
+ messages = ["""<s><<SYS>>List the key points with details from the next message.<</SYS>>"""]
21
+
22
+
23
+ def transcript_audio(audio_file):
24
+ # Initialize the speech recognition pipeline
25
+ pipe = pipeline(
26
+ "automatic-speech-recognition",
27
+ model="openai/whisper-small",
28
+ chunk_length_s=30,
29
+ device=0 if torch.cuda.is_available() else -1,
30
+ )
31
+
32
+ # Transcribe the audio file and return the result
33
+ result = pipe(audio_file, batch_size=8)["text"]
34
+
35
+ # Create a human message from the transcribed text
36
+ messages.append(result)
37
+
38
+ return result
39
+
40
+
41
+ # Set up Gradio interface
42
+ audio_input = gr.Audio(sources="upload", type="filepath") # Audio input
43
+ output_text = gr.Textbox() # Text output
44
+
45
+ # Create the Gradio interface with the function, inputs, and outputs
46
+ iface = gr.Interface(fn=transcript_audio,
47
+ inputs=audio_input, outputs=output_text,
48
+ title="Audio Transcription App",
49
+ description="Upload the audio file")
50
+
51
+ # Launch the Gradio app
52
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ aiohappyeyeballs==2.4.3
3
+ aiohttp==3.10.10
4
+ aiosignal==1.3.1
5
+ annotated-types==0.7.0
6
+ anyio==4.6.2.post1
7
+ attrs==24.2.0
8
+ certifi==2024.8.30
9
+ charset-normalizer==3.4.0
10
+ click==8.1.7
11
+ colorama==0.4.6
12
+ fastapi==0.115.3
13
+ ffmpy==0.4.0
14
+ filelock==3.16.1
15
+ frozenlist==1.5.0
16
+ fsspec==2024.10.0
17
+ gradio==5.3.0
18
+ gradio_client==1.4.2
19
+ greenlet==3.1.1
20
+ h11==0.14.0
21
+ httpcore==1.0.6
22
+ httpx==0.27.2
23
+ huggingface-hub==0.26.1
24
+ ibm-cos-sdk==2.13.6
25
+ ibm-cos-sdk-core==2.13.6
26
+ ibm-cos-sdk-s3transfer==2.13.6
27
+ ibm_watson_machine_learning==1.0.364
28
+ idna==3.10
29
+ importlib_metadata==8.5.0
30
+ Jinja2==3.1.4
31
+ jmespath==1.0.1
32
+ joblib==1.4.2
33
+ jsonpatch==1.33
34
+ jsonpointer==3.0.0
35
+ langchain==0.3.4
36
+ langchain-core==0.3.12
37
+ langchain-huggingface==0.1.0
38
+ langchain-text-splitters==0.3.0
39
+ langsmith==0.1.137
40
+ lomond==0.3.3
41
+ markdown-it-py==3.0.0
42
+ MarkupSafe==2.1.5
43
+ mdurl==0.1.2
44
+ mpmath==1.3.0
45
+ multidict==6.1.0
46
+ networkx==3.4.2
47
+ numpy==1.26.4
48
+ orjson==3.10.10
49
+ packaging==24.1
50
+ pandas==2.1.4
51
+ pillow==10.4.0
52
+ propcache==0.2.0
53
+ pydantic==2.9.2
54
+ pydantic_core==2.23.4
55
+ pydub==0.25.1
56
+ Pygments==2.18.0
57
+ python-dateutil==2.9.0.post0
58
+ python-multipart==0.0.12
59
+ pytz==2024.2
60
+ PyYAML==6.0.2
61
+ regex==2024.9.11
62
+ requests==2.32.2
63
+ requests-toolbelt==1.0.0
64
+ rich==13.9.3
65
+ ruff==0.7.1
66
+ safetensors==0.4.5
67
+ scikit-learn==1.5.2
68
+ scipy==1.14.1
69
+ semantic-version==2.10.0
70
+ sentence-transformers==3.2.1
71
+ setuptools==75.2.0
72
+ shellingham==1.5.4
73
+ six==1.16.0
74
+ sniffio==1.3.1
75
+ SQLAlchemy==2.0.36
76
+ starlette==0.41.0
77
+ sympy==1.13.1
78
+ tabulate==0.9.0
79
+ tenacity==9.0.0
80
+ threadpoolctl==3.5.0
81
+ tokenizers==0.20.1
82
+ tomlkit==0.12.0
83
+ torch==2.5.0+cu118
84
+ torchaudio==2.5.0+cu118
85
+ torchvision==0.20.0+cu118
86
+ tqdm==4.66.5
87
+ transformers==4.46.0
88
+ typer==0.12.5
89
+ typing_extensions==4.12.2
90
+ tzdata==2024.2
91
+ urllib3==2.2.3
92
+ uvicorn==0.32.0
93
+ websockets==12.0
94
+ yarl==1.16.0
95
+ zipp==3.20.2