I am agnostic as to which solution I use, but in the following code, the simpleaudio solution causes a segmentation fault, whereas the pygame solution works perfectly. Why is this?
import tkinter as tk
from tkinter import ttk
import simpleaudio as sa
from pygame import mixer
root = tk.Tk()
def main() -> None:
MainFrame()
root.mainloop()
class MainFrame():
"""Define the Main frame."""
def __init__(self):
button = ttk.Button(root, text='Click', command=self.on_click)
button.grid(row=0, column=0)
def on_click(self):
ping = sa.WaveObject.from_wave_file('ping.wav')
play = ping.play()
play.wait_done()
# mixer.init()
# ping = mixer.Sound("ping.wav")
# ping.play()
if __name__ == '__main__':
main()