Skip to content

Commit

Permalink
Use IO.popen block to properly close the resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dejan committed Feb 1, 2017
1 parent 24799f2 commit 1d9a911
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/espeak/speech.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def initialize(text, options={})
# Speaks text
#
def speak
IO.popen(espeak_command(command_options), 'r').read
IO.popen(espeak_command(command_options), 'r') do |process|
process.read
end
end

# Generates mp3 file as a result of
Expand Down Expand Up @@ -52,7 +54,9 @@ def bytes()
# Text-To-Speech conversion.
#
def bytes_wav()
IO.popen(espeak_command(command_options, "--stdout"), 'r').read
IO.popen(espeak_command(command_options, "--stdout"), 'r') do |process|
process.read
end
end

private
Expand Down

0 comments on commit 1d9a911

Please sign in to comment.