bart-khalid commited on
Commit
b85297d
·
verified ·
1 Parent(s): ea7c362

Upload 7 files

Browse files
Files changed (7) hide show
  1. API_URL_BASE.pkl +3 -0
  2. API_URL_MEDIUM.pkl +3 -0
  3. AudioToText.png +0 -0
  4. app.py +117 -0
  5. headers.pkl +3 -0
  6. packages.txt +1 -0
  7. requirements.txt +2 -0
API_URL_BASE.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c3e2380427f7ee8519a5b4f0e9928ecb2a0a6eb86f0e6576d390b87e71b3d18
3
+ size 78
API_URL_MEDIUM.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00d461b19c576c5b86e175fb680aa09e92bc7d0f2a8b3ef977666ad18bcdb88a
3
+ size 80
AudioToText.png ADDED
app.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import Image
2
+
3
+ import streamlit as st
4
+ import requests
5
+ import dill
6
+
7
+ # load icon image
8
+ im = Image.open("AudioToText.png")
9
+ # config
10
+ st.set_page_config(
11
+ page_title="BARTAOUCH Khalid Audio To Text App",
12
+ layout="wide",
13
+ initial_sidebar_state="expanded",
14
+ page_icon=im,
15
+ menu_items={
16
+ 'About': "# BARTAOUCH KHALID Audio To Text APP. This is a free app!"
17
+ }
18
+ )
19
+
20
+ # title
21
+ title = """
22
+ <h1 style="color: orange; text-align:center;"> تحويل أوديو إلى نص </h1>
23
+ </div>
24
+ """
25
+ st.markdown(title,unsafe_allow_html=True)
26
+
27
+ #Author
28
+ author="""
29
+ <style>
30
+ a:link, a:visited{
31
+ color: black;
32
+ background-color: white;
33
+ text-decoration: underline;
34
+ }
35
+ a:hover, a:active {
36
+ color: red;
37
+ background-color: white;
38
+ text-decoration: underline;
39
+ }
40
+ .author{
41
+ width:auto;
42
+ text-align: center;
43
+ padding: 10px;
44
+ z-index: 999999999;
45
+ }
46
+ </style>
47
+ <div class="author">
48
+ <p>Developed with ❤ by &nbsp; <a href="https://www.linkedin.com/in/bartaouchkhalid" target="_blank">** BARTAOUCH Khalid **</a></p>
49
+ </div>
50
+ """
51
+ st.markdown(author,unsafe_allow_html=True)
52
+ st.write('\n')
53
+ st.write('\n')
54
+
55
+ # layout define
56
+ col1, col2, col3 = st.columns([5,4,3])
57
+ x=0
58
+
59
+ # credentials
60
+ with open('API_URL_MEDIUM.pkl', 'rb') as file:
61
+ API_URL_MEDIUM = dill.load(file)
62
+ with open('API_URL_BASE.pkl', 'rb') as file2:
63
+ API_URL_BASE = dill.load(file2)
64
+ with open('headers.pkl', 'rb') as file3:
65
+ headers = dill.load(file3)
66
+
67
+ @st.cache_resource(show_spinner="...طلبكم قيد المعالجة")
68
+ def query_base(data):
69
+ response = requests.post(API_URL_BASE, headers=headers, data=data)
70
+ return response.json()
71
+
72
+ @st.cache_resource(show_spinner="...طلبكم قيد المعالجة")
73
+ def query_medium(data):
74
+ response = requests.post(API_URL_MEDIUM, headers=headers, data=data)
75
+ return response.json()
76
+
77
+ # layout
78
+ with col3:
79
+ option = st.selectbox(
80
+ 'إختر__الخوارزمية__المناسبة__لك',
81
+ ('دقة مناسبة، وقت أسرع', 'دقة أكثر، وقت معالجة أكثر'))
82
+
83
+ if option == 'دقة أكثر، وقت معالجة أكثر' :
84
+ option = 'medium'
85
+ else :
86
+ option = 'base'
87
+
88
+ audio = st.file_uploader("إرفع المقطع الصوتي", type=["mp3", "wav", "ogg", "flac", "m4a", "aac"])
89
+
90
+ with col2:
91
+ if audio is not None:
92
+ st.write('\n')
93
+ with st.spinner("...طلبكم قيد المعالجة"):
94
+ if option == 'base':
95
+ st.info('...لم يتبقى الكثير، المرجو الإنتظار')
96
+ result = query_base(audio.read())
97
+ else :
98
+ st.info('...لم يتبقى الكثير، المرجو الإنتظار')
99
+ result = query_medium(audio.read())
100
+ st.header("النتيجة")
101
+ st.success(result["text"])
102
+ x=1
103
+
104
+ with col1:
105
+ if x==1:
106
+ st.subheader("لنسخ النص")
107
+ st.code(result["text"])
108
+
109
+ #footer
110
+ hide_streamlit_style = """
111
+ <style>
112
+ #MainMenu {visibility: hidden;}
113
+ footer {visibility: hidden;}
114
+ </style>
115
+ """
116
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)
117
+ #footer End
headers.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bb204160924351c37bb73496ca4e83e0dbd581367c1cc107f8fdda11397ff1e
3
+ size 78
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ffmpeg-python
2
+ dill