Ejemplo n.º 1
0
    public void HandleSave()
    {
        if (keys != null && keys.Count > 0 && currentWordLists != null && currentWordLists.Count > 0 && clip != null)
        {
            VoiceConfig data = new VoiceConfig()
            {
                words = currentWordLists,
                times = keys.Select(x => x.recttf.anchoredPosition.x / scrollRect.content.sizeDelta.x * clip.length).ToList()
            };

            string jsonString = JsonUtility.ToJson(data);
            string prevPath   = PlayerPrefs.GetString("LAST_AUDIO_FILE_PATH", "");
            string dirname    = "";
            string filename   = "";
            if (!string.IsNullOrEmpty(prevPath))
            {
                FileInfo      fileinfo = new FileInfo(prevPath);
                DirectoryInfo dir      = fileinfo.Directory;
                dirname = dir.FullName;
                int lastDot = fileinfo.Name.LastIndexOf(".");
                filename = fileinfo.Name.Substring(0, lastDot);
                Debug.Log("fileName: " + filename);
            }
            string path = StandaloneFileBrowser.SaveFilePanel("Open File", dirname, filename, "json");
            if (!string.IsNullOrEmpty(path))
            {
                File.WriteAllText(path, jsonString);
            }
        }
    }
Ejemplo n.º 2
0
 public void LoadVoiceConfig(VoiceConfig data)
 {
     countIdx = 0;
     for (int i = 0; i < data.times.Count; i++)
     {
         HandleAddKeyFrame(data.times[i]);
     }
 }
Ejemplo n.º 3
0
 public VoiceController(ILogger <VoiceController> logger, ILUISRuntimeClient luisRuntimeClient,
                        IDictionary <string, CallState> callStates, VoiceConfig voiceConfig, LuisSettings luisSettings,
                        IHubContext <CallActivityHub> hubContext)
 {
     _logger            = logger;
     _luisRuntimeClient = luisRuntimeClient;
     _callStates        = callStates;
     _voiceConfig       = voiceConfig;
     _luisSettings      = luisSettings;
     _hubContext        = hubContext;
 }
Ejemplo n.º 4
0
 public void OnEndEditZoomScale(string text)
 {
     float.TryParse(text, out float zoomScale);
     multiply = (int)(300 * zoomScale);
     if (clip != null)
     {
         if (keys != null && keys.Count > 0 && currentWordLists != null && currentWordLists.Count > 0)
         {
             VoiceConfig data = new VoiceConfig()
             {
                 words = currentWordLists,
                 times = keys.Select(x => x.recttf.anchoredPosition.x / scrollRect.content.sizeDelta.x * clip.length).ToList()
             };
             LoadAudio(clip);
             Reset();
             LoadVoiceConfig(data);
         }
         else
         {
             LoadAudio(clip);
             Reset();
         }
     }
 }
Ejemplo n.º 5
0
 public Voice(VoiceConfig config)
 {
     _speechConfig = SpeechConfig.FromSubscription(config.ApiKey, config.Location);
 }
Ejemplo n.º 6
0
        public bool Open(XmlNode argNode,
                         string argBasePath,
                         bool argIsRemote)
        {
            Debug.Assert(null != argNode && !string.IsNullOrEmpty(argBasePath));

            try
            {
                m_basePath = argBasePath;
                m_isRemote = argIsRemote;
                Log.ResourceManager.LogDebugFormat("Prepare for opening a resource service [{0}]", m_language);
                if (!argIsRemote)
                {
                    XmlAttribute cfgAttri = null;
                    //Load image config
                    XmlNode imgNode = argNode.SelectSingleNode(s_ImageNode);
                    if (null != imgNode &&
                        imgNode.NodeType == XmlNodeType.Element)
                    {
                        string imgCfg = null;
                        cfgAttri = imgNode.Attributes[s_cfgAttri];
                        if (null != cfgAttri &&
                            !string.IsNullOrEmpty(cfgAttri.Value))
                        {
                            imgCfg = string.Format(@"{0}\{1}\{2}", argBasePath, imgNode.Name, cfgAttri.Value);
                            ImageConfig.Load(imgCfg);
                        }
                    }

                    //Load voice config
                    XmlNode voiceNode = argNode.SelectSingleNode(s_VoiceNode);
                    if (null != voiceNode &&
                        voiceNode.NodeType == XmlNodeType.Element)
                    {
                        string voiceCfg = null;
                        cfgAttri = voiceNode.Attributes[s_cfgAttri];
                        if (null != cfgAttri &&
                            !string.IsNullOrEmpty(cfgAttri.Value))
                        {
                            voiceCfg = string.Format(@"{0}\{1}\{2}", argBasePath, voiceNode.Name, cfgAttri.Value);
                            VoiceConfig.Load(voiceCfg);
                        }
                    }

                    //Load video config
                    XmlNode videoNode = argNode.SelectSingleNode(s_VideoNode);
                    if (null != videoNode &&
                        videoNode.NodeType == XmlNodeType.Element)
                    {
                        string videoCfg = null;
                        cfgAttri = videoNode.Attributes[s_cfgAttri];
                        if (null != cfgAttri &&
                            !string.IsNullOrEmpty(cfgAttri.Value))
                        {
                            videoCfg = string.Format(@"{0}\{1}\{2}", argBasePath, videoNode.Name, cfgAttri.Value);
                            VideoConfig.Load(videoCfg);
                        }
                    }

                    //load text content
                    string       textNodePath = string.Format("{0}/{1}", s_textNode, s_categoryNode);
                    XmlNodeList  listNodes    = argNode.SelectNodes(textNodePath);
                    XmlAttribute nameAttri    = null;
                    string       textFilePath = null;
                    XmlDocument  textDoc      = null;
                    foreach (XmlNode node in listNodes)
                    {
                        nameAttri = node.Attributes[s_nameAttri];
                        if (null == nameAttri ||
                            string.IsNullOrEmpty(nameAttri.Value))
                        {
                            continue;
                        }

                        try
                        {
                            textFilePath = string.Format(@"{0}\{1}\{2}\{3}.xml", argBasePath, s_textNode, m_language, nameAttri.Value);
                            if (!File.Exists(textFilePath))
                            {
                                Log.ResourceManager.LogWarnFormat("The file[{0}] isn't exist", textFilePath);
                                continue;
                            }
                            textDoc = new XmlDocument();
                            textDoc.Load(textFilePath);
                            TextCategories.Add(nameAttri.Value, textDoc);
                        }
                        catch (System.Exception ex)
                        {
                            Log.ResourceManager.LogWarn(string.Format("Failed to open text file[{0}]", textFilePath), ex);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                m_imageConfig = null;
                m_voiceConfig = null;
                m_videoConfig = null;
                if (null != m_dicTextCategories)
                {
                    m_dicTextCategories.Clear();
                    m_dicTextCategories = null;
                }
                Log.ResourceManager.LogError("Failed to open a resource service", ex);
                return(false);
            }

            return(true);
        }