Module: SimpleCaptcha::AudioHelpers
Instance Method Summary collapse
- #generate_simple_audio_captcha(simple_captcha_key) ⇒ Object
- #make_audio_from_captcha(captcha_str) ⇒ Object
- #make_audio_from_char(char) ⇒ Object
Instance Method Details
#generate_simple_audio_captcha(simple_captcha_key) ⇒ Object
7 8 9 10 |
# File 'lib/simple_audio_captcha/audio_helpers.rb', line 7 def generate_simple_audio_captcha(simple_captcha_key) captcha_value = Utils::simple_captcha_value(simple_captcha_key) make_audio_from_captcha(captcha_value) end |
#make_audio_from_captcha(captcha_str) ⇒ Object
12 13 14 15 |
# File 'lib/simple_audio_captcha/audio_helpers.rb', line 12 def make_audio_from_captcha(captcha_str) audio = make_audio_from_char(captcha_str.chars.first) captcha_str.chars.drop(1).inject(audio) { |audio_accumalator, char| audio_accumalator << make_audio_from_char(char) } end |
#make_audio_from_char(char) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/simple_audio_captcha/audio_helpers.rb', line 17 def make_audio_from_char(char) Speech.new(char, voice: SimpleCaptcha.voice, pitch: SimpleCaptcha.pitch, speed: SimpleCaptcha.speed).bytes.force_encoding('ASCII-8BIT') end |