Hamza2233 commited on
Commit
ec8ac51
·
verified ·
1 Parent(s): 2fec11d

Create app.py

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