Answers for "how to make python play sound files"

6

Play sound in python

import winsound

winsound.PlaySound('sound.wav', winsound.SND_FILENAME)
Posted by: Guest on May-04-2021
-1

play sound directly with pytts

import pyttsx
engine = pyttsx.init()
engine.say('Good morning.')
engine.runAndWait()
Posted by: Guest on April-24-2021
1

how to open sound file in python

# playsound module

from playsound import playsound
playsound('audio.mp3')   # way to your audio file
Posted by: Guest on June-01-2021
0

Create Sound with Python

import os
import glob
from pydub import AudioSegment

video_dir = 'D:/Movies/Urdu Songs/New folder'  # Path where the videos are located
extension_list = ('*.mp4', '*.flv')

os.chdir(video_dir)
for extension in extension_list:
    for video in glob.glob(extension):
        mp3_filename = os.path.splitext(os.path.basename(video))[0] + '.mp3'
        AudioSegment.from_file(video).export(mp3_filename, format='mp3')
Posted by: Guest on August-08-2021

Browse Popular Code Answers by Language