File size: 958 Bytes
1620753 6b694b5 5b29361 6b694b5 1620753 6b694b5 5b29361 6b694b5 5b29361 1620753 6b694b5 1620753 6b694b5 1620753 6b694b5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
import requests
API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3-turbo"
headers = {"Authorization": f"Bearer {st.secrets['HF_API_KEY']}"} # Безопасное хранение токена
def query(file):
try:
response = requests.post(API_URL, headers=headers, data=file.read())
response.raise_for_status() # Проверка на ошибки HTTP
return response.json()
except requests.exceptions.RequestException as e:
st.error(f"Ошибка запроса к API: {e}")
return None
st.title("Транскрипция аудио")
uploaded_file = st.file_uploader("Загрузите аудиофайл", type=["wav", "mp3", "flac"])
if uploaded_file is not None:
with st.spinner("Транскрибируется..."):
output = query(uploaded_file)
if output:
st.text_area("Транскрипт:", value=output["text"]) |