import streamlit as st import requests # # Print out all secrets to check what is available # st.write(st.secrets) # # Access the secret with the key "CTP_DATASCIENCE" (if that's how you've stored it) CTP_DATASCIENCE = st.secrets.get("CTP_DATASCIENCE") # # Check if the API key is available # if CTP_DATASCIENCE: # st.success("API key found!") # else: # st.error("API key not found!") # Set up the headers for the Hugging Face API request using the API key headers = {"Authorization": f"Bearer {CTP_DATASCIENCE}"} # Define the Hugging Face API URL (for Whisper model, in this case) API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3-turbo" # Function to make the API request with the given file def query(filename): with open(filename, "rb") as f: data = f.read() response = requests.post(API_URL, headers=headers, data=data) return response.json() # Example usage with a sample audio file output = query("sample1.flac") # Display the output of the API request st.write(output)