Last active
October 16, 2020 02:11
-
-
Save Heavyblade/19bded74b8bd09efa5c6cf6940f8b614 to your computer and use it in GitHub Desktop.
video_to_text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "google/cloud/speech" | |
speech = Google::Cloud::Speech.speech | |
File.open("out.txt", "w") do |file| | |
n = 16 | |
(1..n).to_a.each do |x| | |
filename = "solo_audio_#{x}" | |
config = { | |
encoding: :LINEAR16, | |
sample_rate_hertz: 16_000, | |
language_code: "es-CO" | |
} | |
audio = { uri: "gs://audiosnana/#{filename}.wav" } | |
operation = speech.long_running_recognize config: config, audio: audio | |
puts "Operation started" | |
operation.wait_until_done! | |
raise operation.results.message if operation.error? | |
results = operation.response.results | |
results.each do |rs| | |
rs.alternatives.each do |alternative| | |
puts alternative.transcript | |
file.write alternative.transcript | |
file.write " " | |
end | |
end | |
end | |
end | |
puts "xxxxxx end xxxxx" | |
#alternatives = results.first.alternatives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extract audio from MP4 | |
ffmpeg -i flavio_chavez.mp4 flavio_chavez.mp3 | |
// Split resulting audio | |
mp3splt -t 8.0 solo_audio.mp3 | |
// rename the audios files to something enum | |
// Convert the mp3 to wav files | |
ruby towav.rb | |
// upload the wab files to google cloud storge | |
// Run the conversor.rb to collect all the extracted data | |
ruby conversor.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 14 | |
(1..n).to_a.each do |x| | |
filename = "fundacion_nal_#{x}" | |
system("ffmpeg -i /home/cristianvasquez/nanatrascripcion/#{filename}.mp3 -acodec pcm_s16le -ac 1 -ar 16000 /home/cristianvasquez/nanatrascripcion/#{filename}.wav") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment