grayphite commited on
Commit
ccee59f
·
verified ·
1 Parent(s): 2cd62cd

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +22 -0
  2. caller_v2.py +55 -0
  3. greetings.mp3 +0 -0
  4. requirements.txt +60 -0
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /usr/src/app
4
+ COPY . .
5
+
6
+ RUN apt-get update && apt-get install -y git
7
+ # Install dependencies from requirements.txt
8
+ RUN pip3 install --no-cache-dir -r requirements.txt
9
+
10
+ #RUN pip3 uninstall gradio_client
11
+
12
+ #RUN pip3 install https://gradio-pypi-previews.s3.amazonaws.com/4bc495cb68aec014cffffce16c14ee1ddaacf7a3/gradio-4.41.0-py3-none-any.whl
13
+ #RUN pip3 install "gradio-client @ git+https://github.com/gradio-app/gradio@4bc495cb68aec014cffffce16c14ee1ddaacf7a3#subdirectory=client/python"
14
+
15
+ # Expose the port for Gradio
16
+ EXPOSE 7860
17
+
18
+ # Set the Gradio server name
19
+ ENV GRADIO_SERVER_NAME="0.0.0.0"
20
+
21
+ # Run the application
22
+ CMD ["python", "-u", "caller_v2.py"]
caller_v2.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from typing import Iterator
3
+ import gradio as gr
4
+ from groq import Groq
5
+ from elevenlabs.client import ElevenLabs
6
+ import logging as log
7
+
8
+ # Initialize Groq client
9
+ client = Groq(api_key="")
10
+ elevenlabs_client = ElevenLabs(
11
+ api_key=""
12
+ )
13
+
14
+
15
+
16
+ def transcribe_audio(audio_file_path, language, additional_text):
17
+ try:
18
+ bytes_data = open('greetings.mp3', 'rb').read()
19
+ yield "Checking ...", bytes_data
20
+
21
+ except Exception as e:
22
+ print(f"error: {e}")
23
+ log.info(f'error: {e}')
24
+ yield f"An error occurred: {str(e)}", None
25
+
26
+
27
+ def speach_to_text():
28
+ # List of supported languages (this is an example, adjust based on Groq's actual supported languages)
29
+ languages = ["en", "ba", "ms", "is", "no", "id"]
30
+
31
+ # Create Gradio interface
32
+ iface = gr.Interface(
33
+ fn=transcribe_audio,
34
+ inputs=[
35
+ gr.Audio(type="filepath", label="Upload Audio File"),
36
+ gr.Dropdown(choices=languages, label="Select Language", value="en"),
37
+ # gr.Radio(["standard", "high"], label="Transcription Quality", value="standard"),
38
+ gr.Textbox(label="Additional Text", placeholder="Enter any additional context or instructions here...")
39
+ ],
40
+ outputs=[
41
+ gr.Textbox(label="Response"),
42
+ gr.Audio(label="Audio Stream", autoplay=True, format="mp3")
43
+ ],
44
+ title="Groq Speech-to-Text Transcription",
45
+ description="Upload an audio file, set parameters, and provide additional text for context in the "
46
+ "transcription process."
47
+ )
48
+
49
+ # Launch the interface
50
+ iface.launch()
51
+
52
+
53
+ # Press the green button in the gutter to run the script.
54
+ if __name__ == '__main__':
55
+ speach_to_text()
greetings.mp3 ADDED
Binary file (37.6 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ annotated-types==0.7.0
3
+ anyio==4.4.0
4
+ certifi==2024.7.4
5
+ charset-normalizer==3.3.2
6
+ click==8.1.7
7
+ contourpy==1.2.1
8
+ cycler==0.12.1
9
+ distro==1.9.0
10
+ elevenlabs==1.7.0
11
+ fastapi==0.112.0
12
+ ffmpy==0.4.0
13
+ filelock==3.15.4
14
+ fonttools==4.53.1
15
+ fsspec==2024.6.1
16
+ gradio @ https://gradio-pypi-previews.s3.amazonaws.com/3dbb412d75a463affc00898b24ade9eb5116e07b/gradio-4.41.0-py3-none-any.whl#sha256=c6a08ed04050cbf8c8d17a5ee3d23af8dc2d793bef53a3a519c299f8a84f07dc
17
+ gradio_client @ git+https://github.com/gradio-app/gradio@4bc495cb68aec014cffffce16c14ee1ddaacf7a3#subdirectory=client/python
18
+ groq==0.9.0
19
+ h11==0.14.0
20
+ httpcore==1.0.5
21
+ httpx==0.27.0
22
+ huggingface-hub==0.24.5
23
+ idna==3.7
24
+ importlib_resources==6.4.0
25
+ Jinja2==3.1.4
26
+ kiwisolver==1.4.5
27
+ markdown-it-py==3.0.0
28
+ MarkupSafe==2.1.5
29
+ matplotlib==3.9.2
30
+ mdurl==0.1.2
31
+ numpy==2.0.1
32
+ orjson==3.10.7
33
+ packaging==24.1
34
+ pandas==2.2.2
35
+ pillow==10.4.0
36
+ pydantic==2.8.2
37
+ pydantic_core==2.20.1
38
+ pydub==0.25.1
39
+ Pygments==2.18.0
40
+ pyparsing==3.1.2
41
+ python-dateutil==2.9.0.post0
42
+ python-multipart==0.0.9
43
+ pytz==2024.1
44
+ PyYAML==6.0.2
45
+ requests==2.32.3
46
+ rich==13.7.1
47
+ ruff==0.5.7
48
+ semantic-version==2.10.0
49
+ shellingham==1.5.4
50
+ six==1.16.0
51
+ sniffio==1.3.1
52
+ starlette==0.37.2
53
+ tomlkit==0.12.0
54
+ tqdm==4.66.5
55
+ typer==0.12.3
56
+ typing_extensions==4.12.2
57
+ tzdata==2024.1
58
+ urllib3==2.2.2
59
+ uvicorn==0.30.6
60
+ websockets==12.0