Skip to content

Commit 5bc7a1b

Browse files
authored
Merge pull request metafy-social#411 from personal-use1/new_branch_artgoblin
New branch artgoblin
2 parents c77b4ba + d656798 commit 5bc7a1b

File tree

11 files changed

+459
-0
lines changed

11 files changed

+459
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
# C extensions
5+
*.so
6+
7+
# Distribution / packaging
8+
bin/
9+
build/
10+
develop-eggs/
11+
dist/
12+
eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
*.egg-info/
19+
.installed.cfg
20+
*.egg
21+
22+
# Installer logs
23+
pip-log.txt
24+
pip-delete-this-directory.txt
25+
26+
# Unit test / coverage reports
27+
.tox/
28+
.coverage
29+
.cache
30+
nosetests.xml
31+
coverage.xml
32+
33+
# Translations
34+
*.mo
35+
36+
# Mr Developer
37+
.mr.developer.cfg
38+
.project
39+
.pydevproject
40+
41+
# Rope
42+
.ropeproject
43+
44+
# Django stuff:
45+
*.log
46+
*.pot
47+
48+
# Sphinx documentation
49+
docs/_build/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Voice_assisted_musicplayer
2+
This project contains Ai powered voice activated music player system.
3+
The system supports mp3,wav and mpeg audio files.
4+
It can also play songs according to yor emotion(files need to be stored in voice_assisted_musicplayer/Songs/[-] **folder name according to your choice**)
5+
It can also load music files form other directories.
6+
7+
To run the program execute the assistant.py file and say the desired song according to your mood
8+
# preview
9+
![image](https://user-images.githubusercontent.com/115635715/195788102-1906c8b2-edd7-456b-9a10-7130bfb19704.png)
10+
11+
![image](https://user-images.githubusercontent.com/115635715/195788334-144aab6a-bb67-42a1-a427-63ceef34a8fe.png)
12+
13+
14+
## Features of the music player:
15+
-backward button<br>
16+
-forward button<br>
17+
-pause/play button<br>
18+
-progress bar<br>
19+
-volume button<br>
20+
-delete button<br>
21+
-load file button<br>
22+
23+
24+
## Requirements:<br>
25+
pyttsx3<br>
26+
SpeechRecognition<br>
27+
os<br>
28+
datetime<br>
29+
pickle<br>
30+
tkinter<br>
31+
pygame<br>
32+
mutagen<br>
33+
time<br>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import pyttsx3
2+
import speech_recognition as sr
3+
import datetime
4+
import os
5+
from player import run
6+
7+
engine = pyttsx3.init('sapi5')
8+
voices = engine.getProperty('voices')
9+
engine.setProperty('voice', voices[1].id)
10+
11+
playlist = []
12+
13+
14+
def speak(audio):
15+
engine.say(audio)
16+
engine.runAndWait()
17+
18+
19+
def bot_answer(answer):
20+
print("assistant:", answer)
21+
22+
23+
def greetings():
24+
global playlist
25+
hour = int(datetime.datetime.now().hour)
26+
if(hour >= 0 and hour < 12):
27+
speak("good morning")
28+
elif hour >= 12 and hour < 18:
29+
speak("good afternoon")
30+
else:
31+
speak("good evening")
32+
33+
speak("welcome to py-Musicplayer")
34+
bot_answer('say playlist name to play')
35+
playlist = os.listdir('Songs')
36+
bot_answer(playlist)
37+
38+
39+
def action_taker():
40+
r = sr.Recognizer()
41+
with sr.Microphone() as source:
42+
print("Listening...")
43+
speak("listening")
44+
r.adjust_for_ambient_noise(source, duration=5)
45+
audio = r.listen(source)
46+
47+
try:
48+
print("recognizing...")
49+
speak("recognizing")
50+
command = r.recognize_google(audio)
51+
print(f'User:{command}\n"')
52+
53+
except Exception as e:
54+
print(e)
55+
bot_answer("Say that again please....")
56+
57+
return "None"
58+
return command
59+
60+
61+
greetings()
62+
while True:
63+
command = action_taker().lower()
64+
song_playlist = list(map(str.lower, playlist))
65+
66+
if any(command in s for s in song_playlist):
67+
get_ind = song_playlist.index(command)
68+
playlist_name = playlist.index(command)
69+
playlist_name = playlist[get_ind]
70+
playlist_dir = os.path.abspath("./Songs/"+playlist_name)
71+
bot_answer('Playing: '+playlist_name +
72+
'playlist for you with Musicplayer')
73+
speak('playing:'+playlist_name+'playlist for you with music player')
74+
print(playlist_dir)
75+
run(playlist_dir)
76+
elif 'stop' in command:
77+
speak('good bye,have a good day')
78+
bot_answer('exit')
79+
engine.stop()
80+
break
81+
else:
82+
bot_answer('did not get the playlist...')
83+
speak('did not get the playlist')
84+
print(playlist)
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)