Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- structure of the project directory:
- audio_problem
- ├──main.py
- └──audio
- └──toms_diner.mp3
- """
- import os
- #placeholder method since I don't have an AudioSegment class
- def AudioSegment_from_mp3(filename):
- print("Reading file", filename)
- with open(filename) as file:
- return file.read()
- def mp3_to_wav(audio_file_name):
- if audio_file_name.split('.')[1] == 'mp3':
- sound = AudioSegment_from_mp3(audio_file_name)
- if __name__ == "__main__":
- dir_path = os.path.join(os.path.dirname(__file__), 'audio')
- for file_name in os.listdir(dir_path):
- file_path = os.path.join(os.path.dirname(__file__), 'audio', file_name)
- #file_path = os.path.join(dir_path, file_name)
- mp3_to_wav(file_path)
- print("If you can see this, the program ran without crashing.")
- #
- #Result:
- #Reading file C:\Users\Kevin\Desktop\audio_problem\audio\toms_diner.mp3
- #If you can see this, the program ran without crashing.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement