Assuming you figured how to play an audio file in Swift, now you want to play with the speed of the audio. The rate property of the AVAudioPlayer object is what you need to change up the speed. The catch is that you need to set the enableRate property to true before you can actually do this.
In this example I create a helper function to set things up. audioPlayer is my instance of AVAudioPlayer. I set currentTime in my use case to start the audio from the beginning. It is also a good practice to stop the audio before playing.
Then I call that function in my actions
That’s it mainly.