<commit_before>require 'cgi' #Required for url_encode
include ESpeak #Required for audio functionality

class AudiosController < ApplicationController
  # GET /audios
  # GET /audios.json
  def index
    @audios = Audio.all
  end

  # GET /audios/1
  # GET /audios/1.json
  def show
    @audio = set_audio
  end

  # GET /audios/new
  def new
    @audio = Audio.new
  end

  # GET /audios/1/edit
  def edit
    @audio = set_audio
  end

  # POST /audios
  # POST /audios.json
  def create
    @audio = Audio.new({ :text => audio_params[:text], :file => @file })
    @file = set_file_name(audio_params[:text])
    @url = @audio.url_path + @file # Creates the url to store
    @file_path = @audio.path + @file
    create_file = create_audio_file(audio_params[:text])
    say_text
    stream_audio

    respond_to do |format|
      if audio_params[:store] == "0" && @file_path.present? # If stream only
        delete_stream_file
        format.html { redirect_to new_audio_path, notice: 'Audio was sent for streaming.'}
        format.json { render :show, status: :created, location: @url }
      elsif audio_params[:store] == "1" && @file_path.present? # If stream and save
        if @audio.save
          format.html { redirect_to @audio, notice: 'Audio was successfully created.' }
          format.json { render :show, status: :created, location: @url }
        else
          format.html { render :new }
          format.json { render json: @audio.errors, status: :unprocessable_entity }
        end
      else
        format.html { render :new }
        format.json { render json: @audio.errors, status: :unprocessable_entity }
      end
    end
  end

  def ass_bot
    @audio = Audio.new
    @file = set_file_name(params[:text])
    @url = @audio.url_path + @file # Creates the url to store
    @file_path = @audio.path + @file
    create_file = create_audio_file(params[:text])
    said = say_text
    stream = stream_audio

    res = {<commit_msg>Fixed issue with file name getting stored properly.<commit_after>require 'cgi' #Required for url_encode
include ESpeak #Required for audio functionality

class AudiosController < ApplicationController
  # GET /audios
  # GET /audios.json
  def index
    @audios = Audio.all
  end

  # GET /audios/1
  # GET /audios/1.json
  def show
    @audio = set_audio
  end

  # GET /audios/new
  def new
    @audio = Audio.new
  end

  # GET /audios/1/edit
  def edit
    @audio = set_audio
  end

  # POST /audios
  # POST /audios.json
  def create
    @audio = Audio.new
    @file = set_file_name(audio_params[:text])
    @url = @audio.url_path + @file # Creates the url to store
    @file_path = @audio.path + @file
    create_file = create_audio_file(audio_params[:text])
    say_text
    stream_audio

    respond_to do |format|
      if audio_params[:store] == "0" && @file_path.present? # If stream only
        delete_stream_file
        format.html { redirect_to new_audio_path, notice: 'Audio was sent for streaming.'}
        format.json { render :show, status: :created, location: @url }
      elsif audio_params[:store] == "1" && @file_path.present? # If stream and save
        @audio = Audio.new({ :text => audio_params[:text], :file => @file })
        if @audio.save
          format.html { redirect_to @audio, notice: 'Audio was successfully created.' }
          format.json { render :show, status: :created, location: @file }
        else
          format.html { render :new }
          format.json { render json: @audio.errors, status: :unprocessable_entity }
        end
      else
        format.html { render :new }
        format.json { render json: @audio.errors, status: :unprocessable_entity }
      end
    end
  end

  def ass_bot
    @audio = Audio.new
    @file = set_file_name(params[:text])
    @url = @audio.url_path + @file # Creates the url to store
    @file_path = @audio.path + @file
    create_file = create_audio_file(params[:text])
    said = say_text
    stream = stream_audio

    res = {
{'fraction_non_alphanumeric': 0.10759175465057819, 'fraction_numerical': 0.002513826043237808, 'mean_word_length': 2.694521819870009, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6337048', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1255, 'n_words': 359}