Download app.py from Hamza2233/clock: direct link, hf CLI and curl.
- Browser
- Download file 983 Bytes
-
https://huggingface.co/spaces/Hamza2233/clock/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hamza2233/clock/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hamza2233/clock/resolve/main/app.py
983 Bytes
| 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() |