Module: PWN::Plugins::Voice
- Defined in:
- lib/pwn/plugins/voice.rb
Overview
This plugin is used for converting Speech to Text, Text to Speech, and Realtime Voice Mutation
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.help ⇒ Object
Display Usage for this Module.
-
.mutate(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::Voice.mutate( sox_path: ‘optional - path to sox application (defaults to /usr/bin/sox)’, pitch: ‘optional - integer to alter voice input (defaults to -300)’ ).
-
.speech_to_text(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::Voice.speech_to_text( audio_file_path: ‘required - path to audio file’, whisper_path: ‘optional - path to OpenAI whisper application (defaults to /usr/local/bin/whisper)’, model: ‘optional - transcribe model to use (defaults to tiny)’, output_dir: ‘optional - directory to output results (defaults to .)’ ).
-
.text_to_speech(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::Voice.text_to_speech( text_path: ‘required - path to text file to speak’, festival_path: ‘optional - path to festival (defaults to /usr/bin/festival)’, voice: ‘optional - voice to use (defaults to cmu_us_slt_arctic_hts)’, ).
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
112 113 114 115 116 |
# File 'lib/pwn/plugins/voice.rb', line 112 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.help ⇒ Object
Display Usage for this Module
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/pwn/plugins/voice.rb', line 120 public_class_method def self.help puts "USAGE: #{self}.mutate( sox_path: 'optional - path to sox application (defaults to /usr/bin/sox)', pitch: 'optional - integer to alter voice input (defaults to -300)' ) response = #{self}.speech_to_text( audio_file_path: 'required - path to audio file', whisper_path: 'optional - path to OpenAI whisper application (defaults to /usr/local/bin/whisper)', model: 'optional - transcribe model to use (defaults to tiny)', output_dir: 'optional - directory to output results (defaults to .)' ) #{self}.text_to_speech( text_path: 'required - path to text file to speak', festival_path: 'optional - path to festival (defaults to /usr/bin/festival)', voice: 'optional - voice to use (defaults to cmu_us_slt_arctic_hts)', ) #{self}.authors " end |
.mutate(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::Voice.mutate(
sox_path: 'optional - path to sox application (defaults to /usr/bin/sox)', pitch: 'optional - integer to alter voice input (defaults to -300)'
)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pwn/plugins/voice.rb', line 17 public_class_method def self.mutate(opts = {}) sox_path = opts[:sox_path] sox_path ||= '/usr/bin/sox' pitch = opts[:pitch].to_i pitch = -300 if pitch.zero? raise "SOX Not Found: #{sox_path}" unless File.exist?(sox_path) puts 'Press CTRL+C to Exit....' system( sox_path, '--default-device', '--default-device', '--no-show-progress', 'pitch', '-q', pitch.to_s, 'contrast', '63' ) puts "\nGoodbye." rescue Interrupt puts "\n#{self}.#{__method__} => Goodbye." rescue StandardError => e raise e end |
.speech_to_text(opts = {}) ⇒ Object
- Supported Method Parameters
-
response = PWN::Plugins::Voice.speech_to_text(
audio_file_path: 'required - path to audio file', whisper_path: 'optional - path to OpenAI whisper application (defaults to /usr/local/bin/whisper)', model: 'optional - transcribe model to use (defaults to tiny)', output_dir: 'optional - directory to output results (defaults to .)'
)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/pwn/plugins/voice.rb', line 53 public_class_method def self.speech_to_text(opts = {}) audio_file_path = opts[:audio_file_path] whisper_path = opts[:whisper_path] whisper_path ||= '/usr/local/bin/whisper' model = opts[:model] model ||= 'tiny' output_dir = opts[:output_dir] output_dir ||= '.' raise "Speech-to-Text Engine Not Found: #{whisper_path}" unless File.exist?(whisper_path) system( whisper_path, audio_file_path, '--model', model, '--output_dir', output_dir ) rescue Interrupt puts "\n#{self}.#{__method__} => Goodbye." rescue StandardError => e raise e end |
.text_to_speech(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::Voice.text_to_speech(
text_path: 'required - path to text file to speak', festival_path: 'optional - path to festival (defaults to /usr/bin/festival)', voice: 'optional - voice to use (defaults to cmu_us_slt_arctic_hts)',
)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/pwn/plugins/voice.rb', line 85 public_class_method def self.text_to_speech(opts = {}) text_path = opts[:text_path] festival_path = opts[:festival_path] festival_path ||= '/usr/bin/festival' voice = opts[:voice] voice ||= 'cmu_us_slt_arctic_hts' raise "Festival Not Found: #{festival_path}" unless File.exist?(festival_path) raise "Text File Not Found: #{text_path}" unless File.exist?(text_path) text_to_say = File.read(text_path).delete('"') system( festival_path, '--batch', "(voice_#{voice})", "(SayText \"#{text_to_say}\")" ) rescue Interrupt puts "\n#{self}.#{__method__} => Goodbye." rescue StandardError => e raise e end |