FIX: espeak text_to_voice install help
This commit is contained in:
@@ -4,17 +4,23 @@
|
|||||||
# See the file 'doc/COPYING' for copying permission
|
# See the file 'doc/COPYING' for copying permission
|
||||||
#
|
#
|
||||||
class Text_to_voice < BeEF::Core::Command
|
class Text_to_voice < BeEF::Core::Command
|
||||||
require 'espeak'
|
|
||||||
include ESpeak
|
|
||||||
|
|
||||||
def pre_send
|
def pre_send
|
||||||
# Ensure lame and espeak are installed
|
# Check for required binaries
|
||||||
if IO.popen(%w[which lame], 'r').read.to_s.eql?('')
|
if IO.popen(%w[which espeak], 'r').read.to_s.eql?('')
|
||||||
print_error('[Text to Voice] Lame is not in $PATH (apt-get install lame)')
|
print_error('[Text to Voice] eSpeak is not in $PATH (brew install espeak on macOS, apt-get install espeak on Linux)')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if IO.popen(%w[which espeak], 'r').read.to_s.eql?('')
|
if IO.popen(%w[which lame], 'r').read.to_s.eql?('')
|
||||||
print_error('[Text to Voice] eSpeak is not in $PATH (apt-get install espeak)')
|
print_error('[Text to Voice] Lame is not in $PATH (brew install lame on macOS, apt-get install lame on Linux)')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load espeak gem (only if binaries are available)
|
||||||
|
begin
|
||||||
|
require 'espeak'
|
||||||
|
include ESpeak
|
||||||
|
rescue LoadError, StandardError => e
|
||||||
|
print_error("[Text to Voice] Failed to load espeak gem: #{e.message}")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -25,11 +31,18 @@ class Text_to_voice < BeEF::Core::Command
|
|||||||
message = input['value'] if input['name'] == 'message'
|
message = input['value'] if input['name'] == 'message'
|
||||||
language = input['value'] if input['name'] == 'language'
|
language = input['value'] if input['name'] == 'language'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Validate language
|
||||||
|
begin
|
||||||
unless Voice.all.map(&:language).include?(language)
|
unless Voice.all.map(&:language).include?(language)
|
||||||
print_error("[Text to Voice] Language '#{language}' is not supported")
|
print_error("[Text to Voice] Language '#{language}' is not supported")
|
||||||
print_more("Supported languages: #{Voice.all.map(&:language).join(',')}")
|
print_more("Supported languages: #{Voice.all.map(&:language).join(',')}")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
rescue StandardError => e
|
||||||
|
print_error("[Text to Voice] Could not validate language: #{e.message}")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
# Convert text to voice, encode as mp3 and write to module directory
|
# Convert text to voice, encode as mp3 and write to module directory
|
||||||
begin
|
begin
|
||||||
|
|||||||
Reference in New Issue
Block a user