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 DeuS · Oct 07, 2013 at 03:18 PM · soundbook

Highlighting of the text according to the sound file(like karaoke)

Hello! I have a text and sound file(i mean the sound file, where it is recorded as someone read this text).

How do I implement highlighting of the text according to the voice acting?(like karaoke) It's for interactive book for children.

So we open the page of the book and hear the author read the text and see highlighting the right words.

Comment
Add comment
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 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by clunk47 · Oct 07, 2013 at 03:36 PM

There's no total speech recognition built into Unity. All you can really do is mess around with the spectrum data, but that would be a long shot. The only thing you can do besides that is sync it all manually. That's with Unity alone. Another thing you could do is look for a Plugin, which you would only be able to use with Unity Pro or Mobile.

Just to help get started a bit, here's an example of how to use SpecData if you decide to go with it.

 using UnityEngine;
 using System.Collections;
 
 public class specData : MonoBehaviour 
 {
     public AudioListener Listener;
     public int numSamples = 128;
     public GameObject abar;
     float[] numberleft;
     float[] numberright;
     GameObject[] thebarsleft;
     GameObject[] thebarsright;
     float spacing;
     float width;
 
     void Start () 
     {
         thebarsleft = new GameObject[numSamples];
         thebarsright = new GameObject[numSamples];
         spacing = .4f - (numSamples * 0.001f);
         width = .1f - (numSamples * 0.001f);
         for(int i=0; i < numSamples; i++)
         { 
             float xpos = i*spacing -8.0f;
             Vector3 positionleft = new Vector3(xpos,3, 0);
                 thebarsleft[i] = (GameObject)Instantiate(abar, positionleft, Quaternion.identity) as GameObject;
                 thebarsleft[i].transform.localScale = new Vector3(width,1,0.2f);
             Vector3 positionright = new Vector3(xpos,-3, 0);
                 thebarsright[i] = (GameObject)Instantiate(abar, positionright, Quaternion.identity) as GameObject;  
                 thebarsright[i].transform.localScale = new Vector3(width,1,0.2f);
         }
 
     }
     
     void Update () 
     {
 
         float[] numberleft = AudioListener.GetSpectrumData (numSamples, 0,FFTWindow.BlackmanHarris);
         float[] numberright = AudioListener.GetSpectrumData (numSamples, 1,FFTWindow.BlackmanHarris);
 
         for(int i=0; i < numSamples; i++){
             if (float.IsInfinity(numberleft[i]*30) || float.IsNaN(numberleft[i]*30)){
 
             }else{
 
                 thebarsleft[i].transform.localScale = new Vector3(width, numberleft[i]*30,0.2f);
 
                 thebarsright[i].transform.localScale = new Vector3(width, numberright[i]*30,0.2f);  
 
             }
 
         }
 
     }
 
 }
Comment
Add comment · Show 3 · 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 DeuS · Oct 07, 2013 at 04:53 PM 0
Share

Thanks! And what are the ways to implement the highlighting letters, words?

avatar image clunk47 · Oct 07, 2013 at 05:50 PM 1
Share

For that, I'd just use GUI.DrawTexture to draw a highlight texture behind the Rect of each word. It will be pretty simple math to get the Rects right. I'm sure there are other ways, but this is how I know you could do it with the GUI class in Unity.

avatar image unityDM_1 clunk47 · Apr 26, 2017 at 11:32 AM 0
Share

Thanks. Do you have any examples or links with you. please share. !

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

17 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 avatar image avatar image avatar image avatar image

Related Questions

Cloud recognition in Vuforia 0 Answers

Audio files not playing at all 4 Answers

How to make the trigger work only once. (SOUND) 1 Answer

Stupid Question of mine-Please take it seriously 1 Answer

Is there any way for implementing auto rap type functionality in Unity3d? 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