python TEst

This commit is contained in:
David Gebert 2021-02-19 14:30:57 +01:00
parent f9e141c320
commit 7e2e1b4dd9
1 changed files with 47 additions and 0 deletions

47
python_template.py Normal file
View File

@ -0,0 +1,47 @@
__author__ = "7509429, Gebert"
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
imported = True
try:
import simpleaudio
except ModuleNotFoundError:
imported = False
import sys, time
'''
playsound('typewriter.mp3', 0)
'''
def play_sound():
if imported:
wave_obj = simpleaudio.WaveObject.from_wave_file\
(os.path.join(dir_path, "typewriter.wav"))
play_obj = wave_obj.play()
return play_obj
return None
def stop_sound(play_obj):
if play_obj is not None:
play_obj.stop()
def print1by1(text, delay=0.1):
for c in text:
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(delay)
print
play_obj = play_sound()
print1by1("Hallo, sehr geehrte Damen und Herren.")
print("\n")
stop_sound(play_obj)