Spaces:
Sleeping
Sleeping
jonnatakusuma
commited on
Commit
•
d73b234
1
Parent(s):
e6498b9
fine tune
Browse files
app.py
CHANGED
@@ -1,31 +1,62 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import whisper
|
3 |
-
from tempfile import NamedTemporaryFile
|
4 |
-
import ffmpeg
|
5 |
|
6 |
|
7 |
-
st.title("MinuteBot App")
|
8 |
|
9 |
-
# upload audio file with streamlit
|
10 |
-
audio_file = st.file_uploader("Unggah Meeting Audio", type=["mp3", "wav", "m4a"])
|
11 |
|
12 |
-
# model = whisper.load_model("base") # loading the base model
|
13 |
-
st.text("MinuteBot Model telah dimuat:")
|
14 |
|
15 |
-
def load_whisper_model():
|
16 |
|
17 |
-
|
18 |
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
if st.sidebar.button("Transkripsikan Audio"):
|
21 |
if audio_file is not None:
|
22 |
with NamedTemporaryFile() as temp:
|
23 |
-
temp.write(audio_file.
|
24 |
temp.seek(0)
|
25 |
-
model =
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
st.
|
31 |
|
|
|
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
# import whisper
|
3 |
+
# from tempfile import NamedTemporaryFile
|
4 |
+
# import ffmpeg
|
5 |
|
6 |
|
7 |
+
# st.title("MinuteBot App")
|
8 |
|
9 |
+
# # upload audio file with streamlit
|
10 |
+
# audio_file = st.file_uploader("Unggah Meeting Audio", type=["mp3", "wav", "m4a"])
|
11 |
|
12 |
+
# # model = whisper.load_model("base") # loading the base model
|
13 |
+
# st.text("MinuteBot Model telah dimuat:")
|
14 |
|
15 |
+
# def load_whisper_model():
|
16 |
|
17 |
+
# return model
|
18 |
|
19 |
|
20 |
+
# if st.sidebar.button("Transkripsikan Audio"):
|
21 |
+
# if audio_file is not None:
|
22 |
+
# with NamedTemporaryFile() as temp:
|
23 |
+
# temp.write(audio_file.getvalue())
|
24 |
+
# temp.seek(0)
|
25 |
+
# model = whisper.load_model("large")
|
26 |
+
# result = model.transcribe(temp.name)
|
27 |
+
# st.write(result["text"])
|
28 |
+
|
29 |
+
# st.sidebar.header("Putar Berkas Audio")
|
30 |
+
# st.sidebar.audio(audio_file)
|
31 |
+
|
32 |
+
import streamlit as st
|
33 |
+
from tempfile import NamedTemporaryFile
|
34 |
+
import ffmpeg
|
35 |
+
from transformers import Wav2Vec2ForCTC, Wav2Vec2Tokenizer
|
36 |
+
import librosa
|
37 |
+
|
38 |
+
st.title("TemplarX-Medium-Indonesian Transcription App")
|
39 |
+
st.text("Model Whisper (TemplarX-medium-Indonesian) telah dimuat:")
|
40 |
+
|
41 |
+
def load_whisper_model():
|
42 |
+
model_name = "jonnatakusuma/TemplarX-medium-Indonesian"
|
43 |
+
tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_name)
|
44 |
+
model = Wav2Vec2ForCTC.from_pretrained(model_name)
|
45 |
+
return tokenizer, model
|
46 |
+
|
47 |
+
audio_file = st.file_uploader("Unggah Meeting Audio", type=["mp3", "wav", "m4a"])
|
48 |
+
|
49 |
if st.sidebar.button("Transkripsikan Audio"):
|
50 |
if audio_file is not None:
|
51 |
with NamedTemporaryFile() as temp:
|
52 |
+
temp.write(audio_file.read())
|
53 |
temp.seek(0)
|
54 |
+
tokenizer, model = load_whisper_model()
|
55 |
+
# Read the audio file and transcribe using the fine-tuned model
|
56 |
+
audio_path = temp.name
|
57 |
+
audio_input, _ = librosa.load(audio_path, sr=16000)
|
58 |
+
transcription = model.stt(text)
|
59 |
+
st.write(transcription)
|
60 |
|
61 |
+
st.sidebar.header("Putar Berkas Audio")
|
62 |
+
st.sidebar.audio(audio_file, format='audio/wav')
|