古い学校やインディーズのビデオゲームのように、遅れてテキストを印刷するコードがあります。Python 3.6:オーディオをより早く再生する方法
すべてが機能していますが、私が望むやり方ではありません。 今は音が遅すぎるように、サウンドの印刷と再生をより速くします。
これを可能にする方法はありますか?ここで
私のコードは次のとおりです。
注:これはpycharmに遅れたが、端末/ CMDで正常に動作します。
import sys
import time
from pydub import AudioSegment
from pydub.playback import play
def print_delay(string_in):
sound_1 = "text_beep.wav"
sound_play = AudioSegment.from_wav(sound_1)
for char in string_in:
sys.stdout.write(char)
sys.stdout.flush()
play(sound_play)
if char != ",":
time.sleep(0.01)
if char == ".":
time.sleep(0.20)
if char == ",":
time.sleep(0.10)
print("\n")
string_hello = "Hello World, this is a sample text.\nI want want this to print out faster without being delayed by the sound file.\nIs there any faster way to do this?"
print_delay(string_hello)