<commit_before>require 'sinatra'
require 'erb'

require 'logger'
$stdout.sync = true
$stderr.sync = true
$stderr.puts "q2n: routes.rb starting"

if ENV.has_key?('Q2N_DIR')
    filepath = ENV['Q2N_DIR']+"/"
    else
    filepath = ""
end
$stderr.puts "q2n: filepath="+filepath

@soundfont = "/usr/share/sounds/sf2/FluidR3_GM.sf2"
$stderr.puts "q2n: soundfount="+@soundfont

# email via /usr/sbin/sendmail
require 'pony'
Pony.options = { :to => '<EMAIL>', :from => '<EMAIL>' }
#Pony.mail :subject => 'quote2note starting', :body => Time.now.to_s

get '/' do
    $stderr.puts "q2n: route /"
    @symbolinvalid = false
    erb :main
end

get '/action' do
    FileUtils.mkdir_p(ENV['Q2N_DIR'])
    
    @symbol = params[:symbol].upcase
    $stderr.puts "q2n: route /action with " +@symbol
    
    @midifile = %x[ruby quote2note.rb --symbol #{@symbol}].delete("\n")
    
    #Pony.mail :subject => 'quote2note in use', :body => @midifile
    
    if @midifile.include? "ERROR"
        @symbolinvalid = true
        erb :main
        else
        @midifull = filepath + @midifile
        @wavfile  = @midifile.sub(/[^.]+\z/,"wav")
        @wavfull  = filepath + @wavfile
        wav_com = "fluidsynth -F #{@wavfull} #{@soundfont} #{@midifull}"<commit_msg>Debug missing soundfont<commit_after>require 'sinatra'
require 'erb'

require 'logger'
$stdout.sync = true
$stderr.sync = true
$stderr.puts "q2n: routes.rb starting"

if ENV.has_key?('Q2N_DIR')
    filepath = ENV['Q2N_DIR']+"/"
    else
    filepath = ""
end
$stderr.puts "q2n: filepath="+filepath

@soundfont = "/usr/share/sounds/sf2/FluidR3_GM.sf2"
$stderr.puts "q2n: soundfont="+@soundfont

# email via /usr/sbin/sendmail
require 'pony'
Pony.options = { :to => '<EMAIL>', :from => '<EMAIL>' }
#Pony.mail :subject => 'quote2note starting', :body => Time.now.to_s

get '/' do
    $stderr.puts "q2n: route /"
    @symbolinvalid = false
    erb :main
end

get '/action' do
    FileUtils.mkdir_p(ENV['Q2N_DIR'])
    
    @symbol = params[:symbol].upcase
    $stderr.puts "q2n: route /action with " +@symbol
    
    @midifile = %x[ruby quote2note.rb --symbol #{@symbol}].delete("\n")
    
    #Pony.mail :subject => 'quote2note in use', :body => @midifile
    
    if @midifile.include? "ERROR"
        @symbolinvalid = true
        erb :main
        else
        @midifull = filepath + @midifile
        @wavfile  = @midifile.sub(/[^.]+\z/,"wav")
        @wavfull  = filepath + @wavfile
        $stderr.puts @soundfont
        wav_com = "fluidsynth -F #{@wavfull} #{@soundfont} #{@midifull}"
{'fraction_non_alphanumeric': 0.17211500590783774, 'fraction_numerical': 0.011027963765261915, 'mean_word_length': 3.096774193548387, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '160783', 'n_tokens_mistral': 997, 'n_tokens_neox': 996, 'n_words': 205}