Search Unity

Creating a speech synthesizer Dll using microsoft speech.Synthesis for unity

Discussion in 'Scripting' started by MohammadM, Jul 29, 2014.

  1. MohammadM

    MohammadM

    Joined:
    Jun 8, 2014
    Posts:
    28
    Hello.
    So i am trying to create a speech Synthesis Dll to use with unity. this is the code for the dll. its just to test its working and will add functions to it when its works.

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using System.ComponentModel;
    4. using System.Data;
    5. using System.Linq;
    6. using System.Text;
    7. using System.Speech.Synthesis;
    8. using System.Speech.AudioFormat;
    9.  
    10. namespace WindowsFormsApplication4
    11. {
    12.     public partial class Form1
    13.     {
    14.         SpeechSynthesizer synth;
    15.         public Form1()
    16.         {
    17.          
    18.             synth = new SpeechSynthesizer();
    19.             synth.SelectVoiceByHints(VoiceGender.Female);
    20.             synth.Speak("123456789");
    21.         }
    22.  
    23.      
    24.     }
    25. }
    26.  
    this is a class library project using c#. i have referenced the (.net speech.Synthesis). the dll is build as a 3.5.net framework

    after building the dll i have placed it in the plugins folder and called it in a c# script in unity
    Code (CSharp):
    1. void Start () {
    2.  
    3.        
    4.         WindowsFormsApplication4.Form1 voice=new     WindowsFormsApplication4.Form1();
    5.        
    i was getting a internal compiler error until i placed the speech Synthesis Dll that is referanced in my dll in the plugins folder along with the dll i have created

    but now i am getting this error.
    Any idea ?
    Thanks.
     
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Well, your call stack suggests this is a crash from inside SelectVoiceByHints(). Does that code work from outside of Unity?
     
    MohammadM likes this.
  3. MohammadM

    MohammadM

    Joined:
    Jun 8, 2014
    Posts:
    28
    the same code runs if it was a c# WindowsFormsApplication project.:) but when i turn that into a dll and use it with unity that happens :(

    And thank you Graham for responding to my posts. i really appreciate your help .
     
  4. AeonIxion

    AeonIxion

    Joined:
    Sep 3, 2012
    Posts:
    10
    Did you ever find a solution to this?
     
  5. jorrit-de-vries

    jorrit-de-vries

    Joined:
    Aug 7, 2009
    Posts:
    71
    I am running into the same issue, but what could be the case is that the Microsoft.Win32.RegistryKey class in the shipped Mono mscorlib is not fully compatible with the Microsoft version.

    Having a look with ILSpy in the System.Speech dll it shows the method in which the null reference occurs tries to obtain the non-public 'hkey' field of the passed RegistryKey instance using reflection. This field is not available in the mscorlib shipped with Unity.

    If anybody got it working, I would be pleased to know.
     
  6. kolorbook

    kolorbook

    Joined:
    Oct 19, 2013
    Posts:
    2
    Same issue