zak100 Posted October 9, 2020 Share Posted October 9, 2020 Hi, Kindly guide me some code for producing sound or music which I can use for indicating that a computer piece has been killed or the computer has killed the piece. Small file just executable for 2 or 3 secs. I am working in text mode. Zulfi. Link to comment Share on other sites More sharing options...
Ghideon Posted October 9, 2020 Share Posted October 9, 2020 (edited) 55 minutes ago, zak100 said: Kindly guide me some code for producing sound or music which I can use for indicating that a computer piece has been killed or the computer has killed the piece. Small file just executable for 2 or 3 secs. I am working in text mode. print("\a") The line of code plays the bell sound, which differ from environment to environment. It fulfils the requirements stated in OP: It is some code, producing sound or music. It is a small file (one line) and these type of sound files (where files are used) in the OS are usually small and contains a few seconds of sound. It works in text mode*; there will be a visible bell if audio is disabled in the terminal. *) I made a guess what "I am working in text mode" means. Edited October 9, 2020 by Ghideon explanation added and improved 1 Link to comment Share on other sites More sharing options...
fiveworlds Posted October 9, 2020 Share Posted October 9, 2020 Something like that? https://linuxhint.com/play_sound_python/#:~:text=Play Sound Using playsound,the audio filename for playing. 1 Link to comment Share on other sites More sharing options...
Sensei Posted October 10, 2020 Share Posted October 10, 2020 (if you're on Windows) did you try winsound.Beep? https://docs.python.org/3/library/winsound.html 1 Link to comment Share on other sites More sharing options...
zak100 Posted October 14, 2020 Author Share Posted October 14, 2020 Hi, Thanks all, I had a very short time but appreciate your efforts. Any other would definitely benefit from it. However, I used only : print("\a"). This was a great experience. I have once developed cross and zero game but 8-board game proved very lengthy for me and I did it using Python. Definitely this experience woul help me if I learn some ML skills also in Python. God blesses you all. Zulfi. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now