Spaces:
Sleeping
Sleeping
Commit ·
2ce0a69
1
Parent(s): aaf2b16
add dataset
Browse files- README.md +3 -3
- app.py +38 -2
- requirements.txt +3 -1
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 👀
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.17.0
|
| 8 |
app_file: app.py
|
|
|
|
| 1 |
---
|
| 2 |
+
title: eHealth Transcribe
|
| 3 |
emoji: 👀
|
| 4 |
+
colorFrom: white
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.17.0
|
| 8 |
app_file: app.py
|
app.py
CHANGED
|
@@ -5,6 +5,39 @@ import gradio as gr
|
|
| 5 |
from google import genai
|
| 6 |
from google.genai import types
|
| 7 |
import asyncio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def audio_from_bytes(audio_file_path: str):
|
|
@@ -103,7 +136,9 @@ def save_user_data(username, email):
|
|
| 103 |
|
| 104 |
with open(DATA_FILE, "w") as file:
|
| 105 |
json.dump(data, file, indent=4)
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
return data
|
| 108 |
|
| 109 |
|
|
@@ -194,11 +229,12 @@ with gr.Blocks() as demo:
|
|
| 194 |
user_block = gr.Column(visible=False)
|
| 195 |
with user_block:
|
| 196 |
counter_display = gr.Textbox(label="Status Message", interactive=False)
|
|
|
|
| 197 |
gr.Interface(
|
| 198 |
fn=transcribe_and_summarize,
|
| 199 |
inputs=[gr.Audio(type="filepath", sources="microphone"), session],
|
| 200 |
outputs=["text", counter_display, session],
|
| 201 |
-
description="pastikan HP/Laptop memiliki microphone untuk merekam percakapan dokter-pasien menjadi rekam medis SOAP. Akun berlangganan https://ehealth.co.id dapat terintegrasi SATUSEHAT & BPJS secara otomatis",
|
| 202 |
allow_flagging="never",
|
| 203 |
)
|
| 204 |
use_case_description = gr.Markdown(
|
|
|
|
| 5 |
from google import genai
|
| 6 |
from google.genai import types
|
| 7 |
import asyncio
|
| 8 |
+
from datasets import load_dataset, DatasetDict, Dataset
|
| 9 |
+
from huggingface_hub import login
|
| 10 |
+
import datetime
|
| 11 |
+
|
| 12 |
+
# Authenticate with HF token
|
| 13 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 14 |
+
login(token=hf_token)
|
| 15 |
+
dataset_name = "spriambada3/ehealth_transcribe"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def init_dataset():
|
| 19 |
+
try:
|
| 20 |
+
dataset = load_dataset(dataset_name)
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print(e)
|
| 23 |
+
dataset = DatasetDict(
|
| 24 |
+
{"data": Dataset.from_dict({"logintime": [], "email": [], "wa": []})}
|
| 25 |
+
)
|
| 26 |
+
print("init dataset result ")
|
| 27 |
+
print(dataset)
|
| 28 |
+
return dataset
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def add_user(dataset, email, wa):
|
| 32 |
+
new_data = {
|
| 33 |
+
"logintime": datetime.datetime.now(),
|
| 34 |
+
"email": email,
|
| 35 |
+
"wa": wa,
|
| 36 |
+
}
|
| 37 |
+
dataset["data"] = dataset["data"].add_item(new_data)
|
| 38 |
+
dataset.push_to_hub(dataset_name) # Save to HF Hub
|
| 39 |
+
|
| 40 |
+
print("add data successful")
|
| 41 |
|
| 42 |
|
| 43 |
def audio_from_bytes(audio_file_path: str):
|
|
|
|
| 136 |
|
| 137 |
with open(DATA_FILE, "w") as file:
|
| 138 |
json.dump(data, file, indent=4)
|
| 139 |
+
wa = username
|
| 140 |
+
dataset = init_dataset()
|
| 141 |
+
add_user(dataset, email, wa)
|
| 142 |
return data
|
| 143 |
|
| 144 |
|
|
|
|
| 229 |
user_block = gr.Column(visible=False)
|
| 230 |
with user_block:
|
| 231 |
counter_display = gr.Textbox(label="Status Message", interactive=False)
|
| 232 |
+
|
| 233 |
gr.Interface(
|
| 234 |
fn=transcribe_and_summarize,
|
| 235 |
inputs=[gr.Audio(type="filepath", sources="microphone"), session],
|
| 236 |
outputs=["text", counter_display, session],
|
| 237 |
+
description="Halo, pastikan HP/Laptop memiliki microphone untuk merekam percakapan dokter-pasien menjadi rekam medis SOAP. Akun berlangganan https://ehealth.co.id dapat terintegrasi SATUSEHAT & BPJS secara otomatis",
|
| 238 |
allow_flagging="never",
|
| 239 |
)
|
| 240 |
use_case_description = gr.Markdown(
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
gradio==5.17.0
|
| 2 |
python-dotenv==1.0.1
|
| 3 |
-
google-genai
|
|
|
|
|
|
|
|
|
| 1 |
gradio==5.17.0
|
| 2 |
python-dotenv==1.0.1
|
| 3 |
+
google-genai
|
| 4 |
+
huggingface_hub
|
| 5 |
+
datasets
|