jeff1evesque / LeQue

Activate installed microphone, and analyze sound input
13 stars 2 forks source link

Recording audio from browser #326

Closed jeff1evesque closed 10 years ago

jeff1evesque commented 10 years ago

Bash automation does not proceed if we save an audio recording from the browser (no file is found in the recording_converted/ subdirectory), despite its success from manually copying an audio file into the directory:

/var/www/audio-analyzer/audio/recording

So, we will adjust both converter_wav_rate, and converter_wav_text. This will involve changing:

# convert wav file to correct format: 16 bit, 16 kHz, mono
inotifywait ../audio/recording -m -e close_write |

to the following:

# convert wav file to correct format: 16 bit, 16 kHz, mono
inotifywait ../audio/recording -m -e close_write -e create |
jeff1evesque commented 10 years ago

fe8fbe4: did not change the outcome, we will remove it for now.

jeff1evesque commented 10 years ago

The following resolved sub-issues from the issue Reconfigure audio efficiently using ffmpeg attempts to resolve bash automation via the web-browser:

jeff1evesque commented 10 years ago

We incorrectly closed this issue. The issue regarding the translation of audio to text via bash automation within the web browser, still needs to be fixed.

jeff1evesque commented 10 years ago

We know upload.php saves the audio file into the recording/ subdirectory, and contains the following line of code:

...
$saved = move_uploaded_file($tmp_name, $filename) ? 1 : 0;
...

According to the php documentation:

bool move_uploaded_file ( string $filename , string $destination )

This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

0c6df86, a904bc1: Therefore, we add the -e move options to the converter_wav_rate bash script, since we need to watch for the audio files that php moves into the recording/ subdirectory.

jeff1evesque commented 10 years ago

We performed a bash automation via the web browser. Our recording audio.wav was exactly 10.4025 seconds long:

screen shot 2014-07-13 at 10 17 34 am

After Reboot: The translation took under 2 minutes after sudo reboot

$ cd /var/www/audio-analyzer/audio/recording
$ ls -l
-rw-r--r--  1  www-data  www-data  458796  2014-07-13  10:12  audio.wav
$ (cd ../recording_converted && ls -l)
-rw-r--r--  1  www-data  www-data  332906  2014-07-13  10:12  audio.wav
$ (cd ../recording_text && ls -l)
-rw-r--r--  1  root  root  84  2014-07-13  10:14  audio

Repeat Without Reboot: We performed another recording, and saved the audio without sudo reboot, and without removing any audio.wav, or audio files:

screen shot 2014-07-13 at 10 26 44 am

$ cd /var/www/audio-analyzer/audio/recording
$ ls -l
-rw-r--r--  1  www-data  www-data  352300  2014-07-13  10:24  audio.wav
$ (cd ../recording_converted && ls -l)
-rw-r--r--  1  www-data  www-data  255630  2014-07-13  10:24  audio.wav
$ (cd ../recording_text && ls -l)
-rw-r--r--  1  root  root  99  2014-07-13  10:27  audio
jeff1evesque commented 10 years ago

Performing above, that is saving an audio after sudo reboot, then saving another audio immediately after without sudo reboot produces a log that runs inotifywait two times, once for each instance an audio recording was saved.