Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by terraformer · Jan 05, 2013 at 02:54 AM · audioclipgooglehttptts

Google text-to-speech via HTTP

Hi,

i've been experimenting with the TTS functionality of Google Translate which you can access via HTTP in a browser. I have read it uses WAV as audiotype. My code compiles but nothing plays; I can see in the Inspector that the AudioSource Audio Clip is set when the script runs, but when I bring up the Select Audio Clip, it says "Can not show PCM data for this file" and there are 0 bits etc.

Am I missing something here? Would be great to get this working as it would provide many languages for TTS

This is my code, which runs in an Init() function when the app starts.

 var www : WWW = new WWW ("http://translate.google.com/translate_tts?tl=en&q=hello");
 
 yield www; 
 
 VoiceAudio.clip = www.GetAudioClip(false, true, AudioType.WAV);
 
 VoiceAudio.Play();
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image terraformer · Jul 13, 2017 at 08:21 AM 0
Share

Note; this was developed in 2013, before Google blocked this way of using the TTS

7 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by JeffersonReis · Sep 13, 2014 at 06:01 PM

 using UnityEngine;
 using System.Collections;
 using System.Text.RegularExpressions;
 
 
 /// <summary>
 /// <author>Jefferson Reis</author>
 /// <explanation>Works only on Android. To test, change the platform to Android.</explanation>
 /// </summary>
 
 public class GoogleTextToSpeech : MonoBehaviour
 {
         public string words = "Hello";
     
         IEnumerator Start ()
         {
                 // Remove the "spaces" in excess
                 Regex rgx = new Regex ("\\s+");
                 // Replace the "spaces" with "% 20" for the link Can be interpreted
                 string result = rgx.Replace (words, "%20");
                 string url = "http://translate.google.com/translate_tts?tl=en&q=" + result;
                 WWW www = new WWW (url);
                 yield return www;
                 audio.clip = www.GetAudioClip (false, false, AudioType.MPEG);
                 audio.Play ();
         }
     
         void OnGUI ()
         {
                 words = GUI.TextField (new Rect (Screen.width / 2 - 200 / 2, 10, 200, 30), words);
                 if (GUI.Button (new Rect (Screen.width / 2 - 150 / 2, 40, 150, 50), "Speak")) {
                         StartCoroutine (Start ());
                 }
         }
     
     
 }//closes the class
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by $$anonymous$$ · Jan 05, 2013 at 06:13 AM

It uses MP3 format, not WAV.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by terraformer · Jan 05, 2013 at 12:36 PM

Thanks Adam,

Just curious, have you tried this yourself? Anyone else?

I tried (with streaming)

 VoiceClip = www.GetAudioClip(false, true, AudioType.MPEG);

and (without streaming)

 VoiceClip = www.GetAudioClip(false, false, AudioType.MPEG);

but both gives this error: Streaming of '' on this platform is not supported

I also tried to build it as a webplayer, if the 'platform' refers to the runtime environment?

I finally tried to upload the webplayer to a webserver but same thing there.

I develop on MacOSX with Unity 3.5.5

Best regards, T.

Comment
Add comment · Show 19 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image terraformer · Jan 06, 2013 at 04:21 PM 0
Share

I seem to have found the answer why this does not work: Unity uses the file extension to deter$$anonymous$$e the file type ins$$anonymous$$d of $$anonymous$$I$$anonymous$$E (why?)

in this post: http://forum.unity3d.com/threads/77442-Unity-3.2-Strea$$anonymous$$g-of-on-this-platform-is-not-supported-UnityEngine.WWW-get_audio vaughan writes: "http:// 123.akamai. net/123/1_342342_32.mp3?auth$$anonymous$$ey=1234567&dummy=fake.mp3 ... was all that was needed to make it work. So as dreamora pointed out, a file extension doesn't change your file type, but as far as Unity is concerned, it seems to only play nice if you have the right extension, even if the mime-type response is mp3. "

i.e. he added &dummy=fake.mp3 to the URL which can't be done with Google TTS, from what I have seen in my tests

avatar image terraformer · Jan 06, 2013 at 04:35 PM 0
Share

just for kicks I opened Adobe Director, created a Quicktime cast member with the Google TTS url, put it on stage, pressed play: Worked, without a line of script :)

and by the way, Director has had TTS built-in since 2002 (but I would not use it for game dev today)

avatar image terraformer · Jan 06, 2013 at 04:56 PM 0
Share

also tried a the Ter$$anonymous$$al, which creates a mp3 file, it is really odd that Unity can't do this

 curl -A "$$anonymous$$ozilla"
     "http://translate.google.com/translate_tts?tl=en&q=hello+world"
     > hello.mp3

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 102 4896 102 4896 0 0 10392 0 --:--:-- --:--:-- --:--:-- 75323

avatar image terraformer · Jan 06, 2013 at 05:47 PM 0
Share

actually, when I do add &dummy=hello.mp3 in the URL the error message in Unity changes from Strea$$anonymous$$g of '' on this platform is not supported into Strea$$anonymous$$g of 'mp3' on this platform is not supported

It seems everything after the dot . is taken as the name

I tried to use the HT$$anonymous$$L URL Encoding of . which is %2E but that doesn't help

I'm about to give this up

avatar image $$anonymous$$ · Jan 06, 2013 at 10:36 PM 0
Share

That seems a little odd, that is using file type ins$$anonymous$$d of mime, but I'll have a play around now and see what I can get working.

Show more comments
avatar image
0

Answer by fuyangli · Mar 01, 2013 at 11:15 AM

Have you guys found how to make it work?

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image terraformer · Mar 01, 2013 at 02:57 PM 0
Share

A colleague of $$anonymous$$e made a PHP script which takes the Google TTS URL with text and converts the mp3 into an OGG file, and saves it locally. So at least that is the first step. I haven't had so much time to take it from there, but I will make an effort hopefully during the next week to implement it in Unity.

avatar image fuyangli · Mar 01, 2013 at 11:02 PM 0
Share

Amazing. It would be awesome if we could stream it from the internet, but, it won't be avaible for offline play. Thanks for the reply, and keep coding!

avatar image terraformer · Mar 06, 2013 at 07:59 PM 0
Share

Solved! Here is a demo; right now it just says "Google is talking" when the app starts but I will work more on this to say directions (to make Unity games accessible for blind, along with a sound compass); I'll soon publish the PHP and UnityScript in a Github project where the code can be downloaded. Demo: http://people.dsv.su.se/~thomasw/unity_access/soundcompass/ Github project: https://sites.google.com/site/unityaccess/visual

avatar image fuyangli · Mar 06, 2013 at 08:13 PM 0
Share

That's what I wanted to do: Games for Blind people. Terraformer, do you have any kind of contact? Add me in facebook.com/fuyangli so we can talk about what you're doing! It'd be great if we can work together on this!

avatar image terraformer · Mar 06, 2013 at 08:40 PM 0
Share

Hi, I don't use Facebook but you can contact me by e-mail at thomasw@dsv.su.se /$$anonymous$$

avatar image
0

Answer by urfx · Oct 31, 2014 at 10:00 PM

@terraformer @fuyangli

what platform were you trying to build for?

TO FIX this issue in you Unity build settings change from web to android or ios... that should of worked.

p.s. I am also looking for collaborators on plug-ins and or games for blind / VI please PM me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WWW Resolving host timed out 2 Answers

Why do I get Parse error (code 400) from Google Ftiness API in Unity? 0 Answers

Stuck with Importing Google Packages 1 Answer

MMO Timer? 1 Answer

Google Drive Plugin - full access from android device 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges