#!/usr/bin/expect
set transcription_hash [lindex $argv 0];
set youtube_video_id [lindex $argv 1];

spawn ssh root@74.81.189.3 -p 6732
#expect "(yes/no)?"
#send "yes\r"
expect "assword:"
send "bangk!20120710"
send "\r"
expect "]#"

send "\r"
expect "]#"
send "\r"
expect "]#"



####################### GET THE AUDIO FROM YOUTUBE:
send "youtube-dl -f 139 -o '/var/www/html/_other/Transcriber.wiki/tubetotext_audio_to_transcribe_${transcription_hash}.m4a' 'https://www.youtube.com/watch?v=${youtube_video_id}'"

send "\r"
expect "]#"
send "\r"
expect "]#"


send "ls"
send "\r"
expect "]#"
send "\r"
expect "]#"

### ####################### CONVERT THE AUDIO TO WAV:

send "ffmpeg -i '/var/www/html/_other/Transcriber.wiki/tubetotext_audio_to_transcribe_${transcription_hash}.m4a' -r 16k '/var/www/html/_other/Transcriber.wiki/tubetotext_audio_to_transcribe_${transcription_hash}.wav'"

send "\r"
expect "]#"
send "\r"
expect "]#"
send "ls"
send "\r"
expect "]#"
send "\r"
expect "]#"


### ####################### LOAD THE PHP PAGE FOR FURTHER CONVERSION AND TRANSCRIPTION:

send "php -f '/var/www/html/_other/Transcriber.wiki/transcription_engine_flac.nsdb' ${transcription_hash} > '/var/www/html/_other/Transcriber.wiki/tmp_transcription_engine.txt' 2>&1 &"

send "\r"
expect "]#"
send "\r"
expect "]#"



exit





