File size: 983 Bytes
ec8ac51 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import streamlit as st
from datetime import datetime
import time
from transformers import pipeline
# Initialize the text-to-speech pipeline (Hugging Face Model)
tts = pipeline("text-to-speech", model="facebook/tts_transformer-en-ljspeech")
def get_current_time():
# Get the current time in HH:MM:SS format
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
return current_time
def clock_app():
st.title("Hugging Face Clock App")
# Display current time
time_display = st.empty()
while True:
# Get the current time
current_time = get_current_time()
# Update the displayed time
time_display.text(f"Current Time: {current_time}")
# Optionally, use the Hugging Face TTS model to announce the time
tts(f"The current time is {current_time}")
# Wait for 1 second before updating the time
time.sleep(1)
# Run the Streamlit app
if __name__ == "__main__":
clock_app() |