save when running out of lines in voice track
This commit is contained in:
@@ -35,6 +35,18 @@ _, data = wavfile.read(wav_filename)
|
|||||||
new_data = data[0:1]
|
new_data = data[0:1]
|
||||||
new_json = {}
|
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
|
current_sec = 0
|
||||||
searching_for = None
|
searching_for = None
|
||||||
for (audio_guess, possible_sections) in timestamps.items():
|
for (audio_guess, possible_sections) in timestamps.items():
|
||||||
@@ -74,16 +86,7 @@ for (audio_guess, possible_sections) in timestamps.items():
|
|||||||
searching_for = phrase
|
searching_for = phrase
|
||||||
break
|
break
|
||||||
elif choice == 'q':
|
elif choice == 'q':
|
||||||
suffix = "0"
|
save()
|
||||||
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)
|
|
||||||
elif choice == 'u':
|
elif choice == 'u':
|
||||||
choice = getch()
|
choice = getch()
|
||||||
if choice != '/' and choice in takes:
|
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')
|
print(f'{choice} is not a valid option')
|
||||||
|
|
||||||
if searching_for != None:
|
if searching_for != None:
|
||||||
print(f"{searching_for} not found")
|
print(f"{searching_for} not found")
|
||||||
|
|
||||||
|
save()
|
@@ -1,3 +1,7 @@
|
|||||||
requests
|
requests
|
||||||
vosk
|
vosk
|
||||||
scipy
|
numpy
|
||||||
|
scipy
|
||||||
|
simpleaudio
|
||||||
|
wheel
|
||||||
|
getch
|
@@ -1,9 +1,11 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
def arg(num, usage):
|
def arg(num, usage, default=None):
|
||||||
val = ''
|
val = ''
|
||||||
if len(sys.argv) > num:
|
if len(sys.argv) > num:
|
||||||
val = sys.argv[num]
|
val = sys.argv[num]
|
||||||
else:
|
else:
|
||||||
|
if default != None:
|
||||||
|
return default
|
||||||
raise ValueError(usage)
|
raise ValueError(usage)
|
||||||
return val
|
return val
|
Reference in New Issue
Block a user