Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. """
  2. structure of the project directory:
  3. audio_problem
  4. ├──main.py
  5. └──audio
  6. └──toms_diner.mp3
  7. """
  8.  
  9. import os
  10.  
  11. #placeholder method since I don't have an AudioSegment class
  12. def AudioSegment_from_mp3(filename):
  13. print("Reading file", filename)
  14. with open(filename) as file:
  15. return file.read()
  16.  
  17. def mp3_to_wav(audio_file_name):
  18. if audio_file_name.split('.')[1] == 'mp3':
  19. sound = AudioSegment_from_mp3(audio_file_name)
  20.  
  21. if __name__ == "__main__":
  22. dir_path = os.path.join(os.path.dirname(__file__), 'audio')
  23. for file_name in os.listdir(dir_path):
  24. file_path = os.path.join(os.path.dirname(__file__), 'audio', file_name)
  25. #file_path = os.path.join(dir_path, file_name)
  26. mp3_to_wav(file_path)
  27. print("If you can see this, the program ran without crashing.")
  28.  
  29. #
  30. #Result:
  31. #Reading file C:\Users\Kevin\Desktop\audio_problem\audio\toms_diner.mp3
  32. #If you can see this, the program ran without crashing.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement