Assets/SpeechToText/Scripts/Utilities/ThreadedJobs/SoXAudioConversionJob.cs
/// <summary>
/// Attempts to run an SoX process that converts the input audio file to FLAC encoding.
/// </summary>
Attempts to run an SoX process that converts the input audio file to FLAC encoding.
Attempts to run an SoX process that converts the input audio file to FLAC encoding .
void ConvertAudio()
        {
            m_ErrorMessage = null;
            if (File.Exists(m_SoXPath))
            {
                var audioConversionProcess = new Process();
                audioConversionProcess.StartInfo.FileName = m_SoXPath;
                audioConversionProcess.StartInfo.Arguments = m_InputFilePath +
                    " " + Constants.SoXFrequencyOptionName + " " + m_OutputFileFormatting.Frequency +
                    " " + Constants.SoXEncodingBitsOptionName + " " + m_OutputFileFormatting.EncodingBits + 
                    " " + Constants.SoXChannelsOptionName + " " + m_OutputFileFormatting.Channels;
                if (Endianness.SoXEndiannessNames.ContainsKey(m_OutputFileFormatting.Endianness))
                {
                    audioConversionProcess.StartInfo.Arguments += " " + Constants.SoXEndiannessOptionName + 
                        " " + Endianness.SoXEndiannessNames[m_OutputFileFormatting.Endianness];
                }
                if (AudioEncoding.EncodingNames.ContainsKey(m_OutputFileFormatting.EncodingType))
                {
                    audioConversionProcess.StartInfo.Arguments += " " + Constants.SoXEncodingTypeOptionName +
                        " " + AudioEncoding.EncodingNames[m_OutputFileFormatting.EncodingType];
                }
                audioConversionProcess.StartInfo.Arguments += " " + m_OutputFilePath;
                audioConversionProcess.StartInfo.CreateNoWindow = true;
                audioConversionProcess.StartInfo.UseShellExecute = false;
                audioConversionProcess.Start();
                audioConversionProcess.WaitForExit();
                if (!File.Exists(m_OutputFilePath))
                {
                    m_ErrorMessage = "Audio conversion with SoX was unsuccessful.";
                }
            }
            else
            {
                m_ErrorMessage = "Could not locate audio conversion application SoX within StreamingAssets.";
            }
        }
void ConvertAudio ( ) { m_ErrorMessage = null ; if ( File . Exists ( m_SoXPath ) ) { var audioConversionProcess = new Process ( ) ; audioConversionProcess . StartInfo . FileName = m_SoXPath ; audioConversionProcess . StartInfo . Arguments = m_InputFilePath + " " + Constants . SoXFrequencyOptionName + " " + m_OutputFileFormatting . Frequency + " " + Constants . SoXEncodingBitsOptionName + " " + m_OutputFileFormatting . EncodingBits + " " + Constants . SoXChannelsOptionName + " " + m_OutputFileFormatting . Channels ; if ( Endianness . SoXEndiannessNames . ContainsKey ( m_OutputFileFormatting . Endianness ) ) { audioConversionProcess . StartInfo . Arguments += " " + Constants . SoXEndiannessOptionName + " " + Endianness . SoXEndiannessNames [ m_OutputFileFormatting . Endianness ] ; } if ( AudioEncoding . EncodingNames . ContainsKey ( m_OutputFileFormatting . EncodingType ) ) { audioConversionProcess . StartInfo . Arguments += " " + Constants . SoXEncodingTypeOptionName + " " + AudioEncoding . EncodingNames [ m_OutputFileFormatting . EncodingType ] ; } audioConversionProcess . StartInfo . Arguments += " " + m_OutputFilePath ; audioConversionProcess . StartInfo . CreateNoWindow = true ; audioConversionProcess . StartInfo . UseShellExecute = false ; audioConversionProcess . Start ( ) ; audioConversionProcess . WaitForExit ( ) ; if ( ! File . Exists ( m_OutputFilePath ) ) { m_ErrorMessage = " " ; } } else { m_ErrorMessage = " " ; } }
Attempts to run an SoX process that converts the input audio file to FLAC encoding.
Attempts to run an SoX process that converts the input audio file to FLAC encoding .