-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoiceassistantscript.py
34 lines (27 loc) · 1.16 KB
/
voiceassistantscript.py
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
import os
import subprocess
import time
def play_audio_files(directory):
# Get a list of all files in the directory
files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]
# Sort the files to play them in order
files.sort()
for i in range(1):
# Iterate through the files and play them
for file in files:
if file.lower().endswith(('.m4a')):
file_path = os.path.join(directory, file)
print(f"Playing: {file}")
# Use subprocess to call an external player
subprocess.run(["ffplay", "-nodisp", "-autoexit", os.path.join(directory, "wakeword.m4a")])
subprocess.run(["ffplay", "-nodisp", "-autoexit", file_path])
# Add a delay of 1 minute
time.sleep(60)
if __name__ == "__main__":
# Get the directory path from the user
directory_path = "/DIRECTORY/PATH/HERE/"
# Check if the directory exists
if os.path.exists(directory_path):
play_audio_files(directory_path)
else:
print("Directory not found. Please enter a valid directory path.")