예제 #1
0
        // The return type of this function was changed to string instead of bool,
        // so that the function can return the actual path of the saved file, which
        // may be different than simply [Application.dataPath + SpeechToText + Temp + filename]
        // if the user chooses not to overwrite a file of the same name if it exists.
        public static string Save(string fileName, AudioClip clip, bool overwiteIfExists = false)
        {
            var filePath = Path.ChangeExtension(Path.Combine(Path.Combine(Path.Combine(Application.dataPath, Constants.SpeechToTextFolderName), Constants.TempFolderName), fileName), "wav");

            if (!overwiteIfExists)
            {
                filePath = IOUtilities.MakeFilePathUnique(filePath);
            }

            // Make sure directory exists if user is saving to sub dir.
            Directory.CreateDirectory(Path.GetDirectoryName(filePath));

            using (var fileStream = CreateEmpty(filePath))
            {
                ConvertAndWrite(fileStream, clip);

                WriteHeader(fileStream, clip);
            }

            return(filePath); // TODO: return false if there's a failure saving the file
        }
예제 #2
0
 /// <summary>
 /// Initialization function called on the frame when the script is enabled just before any of the Update
 /// methods is called the first time.
 /// </summary>
 void Start()
 {
     m_LogFilePath = IOUtilities.MakeFilePathUnique(Path.Combine(Path.Combine(Application.dataPath, Constants.SpeechToTextFolderName), m_LogFileBaseName));
 }