Is there a way to change the speed of printing something to match the speed of a currently playing audio file?

85 Views Asked by At

I am using the winsound module to play audio files from a folder, and am trying to create a transcript system for a project I am working on. But currently my process of making this is slow and is as follows:

Run code:

  • speech from audio file does not match speed of print() function
  • change the time.sleep() time up or down
  • repeat previous steps

Is there a quicker way of creating this? Perhaps by repeatedly changing the speed of the print statement to match the speed of the audio file in real time?

I am using python 3.8 so if there are any modules that could do this that would help a lot.

Also, here is a sample of the code if it helps:

import winsound

print("You find the access tunnel, hidden within a natural cave a mile off the main road.")
time.sleep(2)
print(" ")
print("You don't need the keycard. The door is ajar.")
time.sleep(2)
print(" ")
print("It smells here. It smells like them. Hopefully, they've moved on. You've come so far
already. You can't turn back now.")
0

There are 0 best solutions below