Spaces:
Runtime error
Runtime error
save
Browse files- .gitattributes +2 -5
- README.md +6 -6
- app.py +96 -0
- requirements.txt +4 -0
- save.sh +3 -0
.gitattributes
CHANGED
@@ -2,13 +2,11 @@
|
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
@@ -16,13 +14,12 @@
|
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
*.pkl filter=lfs diff=lfs merge=lfs -text
|
|
|
22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
@@ -31,4 +28,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
31 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
5 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
|
10 |
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
|
|
14 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
|
|
17 |
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
23 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
|
|
28 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: V-to-text (dev)
|
3 |
+
emoji: 🗣
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system("pip install git+https://github.com/openai/whisper.git")
|
3 |
+
import gradio as gr
|
4 |
+
import whisper
|
5 |
+
from flask import Flask, jsonify, request
|
6 |
+
import requests
|
7 |
+
import streamlit as st
|
8 |
+
import time
|
9 |
+
|
10 |
+
|
11 |
+
model = whisper.load_model("large-v2")
|
12 |
+
|
13 |
+
app = Flask(__name__)
|
14 |
+
|
15 |
+
@app.route("/")
|
16 |
+
def indexApi():
|
17 |
+
return jsonify({"output": "okay"})
|
18 |
+
|
19 |
+
@app.route("/run", methods=['POST'])
|
20 |
+
def runApi():
|
21 |
+
start_time = time.time()
|
22 |
+
|
23 |
+
audio_url = request.form.get("audio_url")
|
24 |
+
# key = request.form.get("key")
|
25 |
+
# modelSelection = request.form.get("model")
|
26 |
+
# print(audio_url)
|
27 |
+
|
28 |
+
# if (modelSelection == None):
|
29 |
+
# modelSelection = "small"
|
30 |
+
# model = whisper.load_model(modelSelection)
|
31 |
+
# print(model)
|
32 |
+
|
33 |
+
# # reject if key not the same
|
34 |
+
# apiKey = st.secrets["Api-Key"]
|
35 |
+
# if apiKey != key:
|
36 |
+
# return jsonify({
|
37 |
+
# "image_url": image_url,
|
38 |
+
# "model": model,
|
39 |
+
# "result": "Invalid API Key",
|
40 |
+
# }), 400
|
41 |
+
|
42 |
+
|
43 |
+
response = requests.get(audio_url)
|
44 |
+
|
45 |
+
if response.status_code == requests.codes.ok:
|
46 |
+
with open("audio.mp3", "wb") as f:
|
47 |
+
f.write(response.content)
|
48 |
+
|
49 |
+
else:
|
50 |
+
return jsonify({
|
51 |
+
"result": "Unable to save file, status code: {response.status_code}" ,
|
52 |
+
}), 400
|
53 |
+
|
54 |
+
# arr = np.asarray(bytearray(response.content), dtype=np.uint8)
|
55 |
+
# result = model.transcribe("audio.mp3")
|
56 |
+
audio = "audio.mp3"
|
57 |
+
|
58 |
+
audio = whisper.load_audio(audio)
|
59 |
+
audio = whisper.pad_or_trim(audio)
|
60 |
+
|
61 |
+
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
62 |
+
|
63 |
+
_, probs = model.detect_language(mel)
|
64 |
+
|
65 |
+
options = whisper.DecodingOptions(fp16 = False)
|
66 |
+
result = whisper.decode(model, mel, options)
|
67 |
+
|
68 |
+
|
69 |
+
end_time = time.time()
|
70 |
+
total_time = end_time - start_time
|
71 |
+
|
72 |
+
return jsonify({
|
73 |
+
"audio_url": audio_url,
|
74 |
+
# "model": model,
|
75 |
+
"result": result.text,
|
76 |
+
"exec_time_sec": total_time
|
77 |
+
})
|
78 |
+
|
79 |
+
if __name__ == "__main__":
|
80 |
+
app.run(host="0.0.0.0", port=7860)
|
81 |
+
|
82 |
+
# def inference(audio):
|
83 |
+
# audio = whisper.load_audio(audio)
|
84 |
+
# audio = whisper.pad_or_trim(audio)
|
85 |
+
|
86 |
+
# mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
87 |
+
|
88 |
+
# _, probs = model.detect_language(mel)
|
89 |
+
|
90 |
+
# options = whisper.DecodingOptions(fp16 = False)
|
91 |
+
# result = whisper.decode(model, mel, options)
|
92 |
+
|
93 |
+
# # print(result.text)
|
94 |
+
# return result.text, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
95 |
+
|
96 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
requests
|
3 |
+
streamlit
|
4 |
+
flask
|
save.sh
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
git add .
|
2 |
+
git commit -m "save"
|
3 |
+
git push origin main
|