|
24 | 24 | using System.IO;
|
25 | 25 | using System.Collections.Generic;
|
26 | 26 | using IBM.Watson.DeveloperCloud.Connection;
|
| 27 | +using UnityEngine.Networking; |
| 28 | +using Utility = IBM.Watson.DeveloperCloud.Utilities.Utility; |
27 | 29 |
|
28 | 30 | public class ExampleSpeechToText : MonoBehaviour
|
29 | 31 | {
|
@@ -700,25 +702,27 @@ private IEnumerator Delay(float delayTime)
|
700 | 702 | private IEnumerator DownloadAcousticResource()
|
701 | 703 | {
|
702 | 704 | Log.Debug("ExampleSpeechToText.DownloadAcousticResource()", "downloading acoustic resource from {0}", _acousticResourceUrl);
|
703 |
| - WWW www = new WWW(_acousticResourceUrl); |
704 |
| - yield return www; |
| 705 | + using (UnityWebRequest unityWebRequest = UnityWebRequest.Get(_acousticResourceUrl)) |
| 706 | + { |
| 707 | + yield return unityWebRequest.SendWebRequest(); |
705 | 708 |
|
706 |
| - Log.Debug("ExampleSpeechToText.DownloadAcousticResource()", "acoustic resource downloaded"); |
707 |
| - _acousticResourceData = www.bytes; |
708 |
| - _isAudioLoaded = true; |
709 |
| - www.Dispose(); |
| 709 | + Log.Debug("ExampleSpeechToText.DownloadAcousticResource()", "acoustic resource downloaded"); |
| 710 | + _acousticResourceData = unityWebRequest.downloadHandler.data; |
| 711 | + _isAudioLoaded = true; |
| 712 | + } |
710 | 713 | }
|
711 | 714 |
|
712 | 715 | private IEnumerator DownloadOggResource()
|
713 | 716 | {
|
714 | 717 | Log.Debug("ExampleSpeechToText", "downloading ogg resource from {0}", _oggResourceUrl);
|
715 |
| - WWW www = new WWW(_oggResourceUrl); |
716 |
| - yield return www; |
| 718 | + using (UnityWebRequest unityWebRequest = UnityWebRequest.Get(_oggResourceUrl)) |
| 719 | + { |
| 720 | + yield return unityWebRequest.SendWebRequest(); |
717 | 721 |
|
718 |
| - Log.Debug("ExampleSpeechToText", "ogg resource downloaded"); |
719 |
| - _oggResourceData = www.bytes; |
720 |
| - _isOggLoaded = true; |
721 |
| - www.Dispose(); |
| 722 | + Log.Debug("ExampleSpeechToText", "ogg resource downloaded"); |
| 723 | + _oggResourceData = unityWebRequest.downloadHandler.data; |
| 724 | + _isOggLoaded = true; |
| 725 | + } |
722 | 726 | }
|
723 | 727 |
|
724 | 728 | private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
|
|
0 commit comments