save when running out of lines in voice track

This commit is contained in:
2021-12-13 20:47:46 -07:00
parent 731d81b99f
commit e5d936ab0c
3 changed files with 24 additions and 13 deletions

View File

@@ -35,6 +35,18 @@ _, data = wavfile.read(wav_filename)
new_data = data[0:1]
new_json = {}
def save():
suffix = "0"
new_wav = wav_filename.replace(".wav", f"-cut{suffix}.wav")
while exists(new_wav):
new_suffix = str(int(suffix) + 1)
new_wav = new_wav.replace(f"-cut{suffix}.wav", f"-cut{new_suffix}.wav")
suffix = new_suffix
wavfile.write(new_wav, framerate, new_data)
with open(new_wav.replace(".wav", ".json"), 'w') as f:
json.dump(new_json, f)
sys.exit(0)
current_sec = 0
searching_for = None
for (audio_guess, possible_sections) in timestamps.items():
@@ -74,16 +86,7 @@ for (audio_guess, possible_sections) in timestamps.items():
searching_for = phrase
break
elif choice == 'q':
suffix = "0"
new_wav = wav_filename.replace(".wav", f"-cut{suffix}.wav")
while exists(new_wav):
new_suffix = str(int(suffix) + 1)
new_wav = new_wav.replace(f"-cut{suffix}.wav", f"-cut{new_suffix}.wav")
suffix = new_suffix
wavfile.write(new_wav, framerate, new_data)
with open(new_wav.replace(".wav", ".json"), 'w') as f:
json.dump(new_json, f)
sys.exit(0)
save()
elif choice == 'u':
choice = getch()
if choice != '/' and choice in takes:
@@ -102,4 +105,6 @@ for (audio_guess, possible_sections) in timestamps.items():
print(f'{choice} is not a valid option')
if searching_for != None:
print(f"{searching_for} not found")
print(f"{searching_for} not found")
save()

View File

@@ -1,3 +1,7 @@
requests
vosk
scipy
numpy
scipy
simpleaudio
wheel
getch

View File

@@ -1,9 +1,11 @@
import sys
def arg(num, usage):
def arg(num, usage, default=None):
val = ''
if len(sys.argv) > num:
val = sys.argv[num]
else:
if default != None:
return default
raise ValueError(usage)
return val