pragnakalp commited on
Commit
9019b20
·
1 Parent(s): ae9b111

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -35,31 +35,27 @@ def one_shot(image,input_text,gender):
35
  sound.export("/content/audio.wav", format="wav")
36
  waveform, sample_rate = torchaudio.load("/content/audio.wav")
37
 
38
- try:
39
- torchaudio.save("/content/audio.wav", waveform, sample_rate, encoding="PCM_S", bits_per_sample=16)
40
- image = Image.open(image_in)
41
- image = pad_image(image)
42
- image.save("/content/image_pre.png")
43
- pocketsphinx_run = subprocess.run(['pocketsphinx', '-phone_align', 'yes', 'single', '/content/audio.wav'], check=True, capture_output=True)
44
- jq_run = subprocess.run(['jq', '[.w[]|{word: (.t | ascii_upcase | sub("<S>"; "sil") | sub("<SIL>"; "sil") | sub("\\\(2\\\)"; "") | sub("\\\(3\\\)"; "") | sub("\\\(4\\\)"; "") | sub("\\\[SPEECH\\\]"; "SIL") | sub("\\\[NOISE\\\]"; "SIL")), phones: [.w[]|{ph: .t | sub("\\\+SPN\\\+"; "SIL") | sub("\\\+NSN\\\+"; "SIL"), bg: (.b*100)|floor, ed: (.b*100+.d*100)|floor}]}]'], input=pocketsphinx_run.stdout, capture_output=True)
45
- with open("test.json", "w") as f:
46
- f.write(jq_run.stdout.decode('utf-8').strip())
47
- import json
48
-
49
- with open('test.json') as user_file:
50
- file_contents = user_file.read()
51
-
52
-
53
-
54
- parsed_json = json.loads(file_contents)
55
- return parsed_json
56
- exit()
57
- os.system(f"cd /content/one-shot-talking-face && python3 -B test_script.py --img_path /content/image_pre.png --audio_path /content/audio.wav --phoneme_path /content/test.json --save_dir /content/train")
58
-
59
- except Exception as e:
60
- print(e)
61
  return parsed_json
62
  exit()
 
 
63
 
64
 
65
 
 
35
  sound.export("/content/audio.wav", format="wav")
36
  waveform, sample_rate = torchaudio.load("/content/audio.wav")
37
 
38
+
39
+ torchaudio.save("/content/audio.wav", waveform, sample_rate, encoding="PCM_S", bits_per_sample=16)
40
+ image = Image.open(image_in)
41
+ image = pad_image(image)
42
+ image.save("/content/image_pre.png")
43
+ pocketsphinx_run = subprocess.run(['pocketsphinx', '-phone_align', 'yes', 'single', '/content/audio.wav'], check=True, capture_output=True)
44
+ jq_run = subprocess.run(['jq', '[.w[]|{word: (.t | ascii_upcase | sub("<S>"; "sil") | sub("<SIL>"; "sil") | sub("\\\(2\\\)"; "") | sub("\\\(3\\\)"; "") | sub("\\\(4\\\)"; "") | sub("\\\[SPEECH\\\]"; "SIL") | sub("\\\[NOISE\\\]"; "SIL")), phones: [.w[]|{ph: .t | sub("\\\+SPN\\\+"; "SIL") | sub("\\\+NSN\\\+"; "SIL"), bg: (.b*100)|floor, ed: (.b*100+.d*100)|floor}]}]'], input=pocketsphinx_run.stdout, capture_output=True)
45
+ with open("test.json", "w") as f:
46
+ f.write(jq_run.stdout.decode('utf-8').strip())
47
+ import json
48
+
49
+ with open('test.json') as user_file:
50
+ file_contents = user_file.read()
51
+
52
+
53
+
54
+ parsed_json = json.loads(file_contents)
 
 
 
 
 
 
55
  return parsed_json
56
  exit()
57
+ os.system(f"cd /content/one-shot-talking-face && python3 -B test_script.py --img_path /content/image_pre.png --audio_path /content/audio.wav --phoneme_path /content/test.json --save_dir /content/train")
58
+
59
 
60
 
61