Download streamlit_app.py from Emma1030/camera: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/spaces/Emma1030/camera/resolve/main/streamlit_app.py
- Command line
-
hf download hf://spaces/Emma1030/camera/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/Emma1030/camera/resolve/main/streamlit_app.py
1.47 kB
| import streamlit as st | |
| import requests | |
| st.set_page_config(page_title="AI 名片備註系統", layout="centered") | |
| st.title("📇 名片辨識 + 語音備註") | |
| st.markdown("請使用下方功能拍攝名片或錄音備註,資料將自動送出後端 API 處理") | |
| # 上傳圖片區塊 | |
| uploaded_image = st.file_uploader("📷 上傳名片照片", type=["jpg", "jpeg", "png"]) | |
| if uploaded_image: | |
| st.image(uploaded_image, caption="預覽名片", use_column_width=True) | |
| if st.button("🚀 送出名片辨識"): | |
| files = {"image": uploaded_image.getvalue()} | |
| with st.spinner("辨識中..."): | |
| try: | |
| res = requests.post("https://你的-ngrok-api-url/ocr", files=files) | |
| st.success("名片辨識結果:") | |
| st.json(res.json()) | |
| except Exception as e: | |
| st.error(f"辨識失敗:{e}") | |
| # 上傳語音區塊 | |
| uploaded_audio = st.file_uploader("🎤 上傳語音備註(wav檔)", type=["wav"]) | |
| if uploaded_audio: | |
| st.audio(uploaded_audio) | |
| if st.button("🧠 送出語音辨識"): | |
| files = {"audio": uploaded_audio.getvalue()} | |
| with st.spinner("語音辨識中..."): | |
| try: | |
| res = requests.post("https://你的-ngrok-api-url/transcribe", files=files) | |
| st.success("語音辨識結果:") | |
| st.json(res.json()) | |
| except Exception as e: | |
| st.error(f"辨識失敗:{e}") | |