[SCRIPT] DLLs pour Unity3D

Présentation des outils annexes/externes à Unity.
Avatar de l’utilisateur
ZJP
Messages : 5745
Inscription : 15 Déc 2009 06:00

[SCRIPT] DLLs pour Unity3D

Message par ZJP » 31 Juil 2010 05:11

Salut,

Ce post me servira a placer au fur et a mesure des DLLs diverses pour Unity (Indie ou Pro). Malheureusement, uniquement pour Windows 32 (ou 64).

Cela commence avec la Synthèse vocale :
La DLL.

le fichier "VoiceSpeaker.cs"

Code : Tout sélectionner

// Voice Speaker  (c) ZJP
 //
// Windows 32B >> Copy 'Voice_speaker.dll' in windows\system32 folder
// Windows 64B >> Copy 'Voice_speaker.dll' in windows\SysWOW64 folder
// Remember to release "Voice_speaker.dll" with your final project. It will be placed in the same folder as the EXE
//
    // Voice Speaker  (c) ZJP //
    using UnityEngine;
    using System;
    using System.Collections;
    using System.Runtime.InteropServices;
     
    public class VoiceSpeaker : MonoBehaviour
    {
        [DllImport ("Voice_speaker.dll", EntryPoint="VoiceAvailable")] private static extern int    VoiceAvailable();
        [DllImport ("Voice_speaker.dll", EntryPoint="InitVoice")]      private static extern void   InitVoice();
        [DllImport ("Voice_speaker.dll", EntryPoint="WaitUntilDone")]  private static extern int    WaitUntilDone(int millisec);
        [DllImport ("Voice_speaker.dll", EntryPoint="FreeVoice")]      private static extern void   FreeVoice();
        [DllImport ("Voice_speaker.dll", EntryPoint="GetVoiceCount")]  private static extern int    GetVoiceCount();

		// Unity V4.x.x
		[DllImport ("Voice_speaker.dll", EntryPoint="GetVoiceName")]   private static extern IntPtr GetVoiceName(int index);
		//  other Unity version
		// [DllImport ("Voice_speaker.dll", EntryPoint="GetVoiceName")]   private static extern string GetVoiceName(int index);

        [DllImport ("Voice_speaker.dll", EntryPoint="SetVoice")]       private static extern void   SetVoice(int index);
        [DllImport ("Voice_speaker.dll", EntryPoint="Say")]            private static extern void   Say(string ttospeak);
        [DllImport ("Voice_speaker.dll", EntryPoint="SayAndWait")]     private static extern void   SayAndWait(string ttospeak);
        [DllImport ("Voice_speaker.dll", EntryPoint="SpeakToFile")]    private static extern int    SpeakToFile(string filename, string ttospeak);
        [DllImport ("Voice_speaker.dll", EntryPoint="GetVoiceState")]  private static extern int    GetVoiceState();
        [DllImport ("Voice_speaker.dll", EntryPoint="GetVoiceVolume")] private static extern int    GetVoiceVolume();
        [DllImport ("Voice_speaker.dll", EntryPoint="SetVoiceVolume")] private static extern void   SetVoiceVolume(int volume);
        [DllImport ("Voice_speaker.dll", EntryPoint="GetVoiceRate")]   private static extern int    GetVoiceRate();
        [DllImport ("Voice_speaker.dll", EntryPoint="SetVoiceRate")]   private static extern void   SetVoiceRate(int rate);
        [DllImport ("Voice_speaker.dll", EntryPoint="PauseVoice")]     private static extern void   PauseVoice();
        [DllImport ("Voice_speaker.dll", EntryPoint="ResumeVoice")]    private static extern void   ResumeVoice();
     
        public int voice_nb = 0;
     
        void Start ()
        {
            if( VoiceAvailable()>0 )
            {
                InitVoice(); // init the engine
				
				if (voice_nb > GetVoiceCount()) voice_nb = 0;
				if (voice_nb < 0) voice_nb = 0;

				// Unity V4.x.x *******************************************
				IntPtr pStr = GetVoiceName(voice_nb);
				string str = Marshal.PtrToStringAnsi(pStr);
                Debug.Log ("Voice name : "+str); // Voice Name
				// Unity V4.x.x *******************************************

                //Debug.Log ("Voice name : "+GetVoiceName(voice_nb)); // Voice Name other Unity version

				Debug.Log ("Number of voice : "+GetVoiceCount()); // Number of voice
               
                SetVoice(voice_nb); // 0 to voiceCount - 1
                Debug.Log ("Voice Rate : "+GetVoiceRate());
                SetVoiceRate(2);
               
                //Debug.Log ("Voice name : "+GetVoiceName(voice_nb));
                Say("All system nominal. Engine, online, weapons, online.. We are ready. 9.,.8.,.7.,.6.,.5.,.4.,.3.,.2.,.1.,.0.,. Go,.Take off");
                // Say("Tout les systèmes sont opérationnels. Moteurs, en ligne. Armement, en ligne. Nous sommes prêt. 9.,.8.,.7.,.6.,.5.,.4.,.3.,.2.,.1.,.0.,. .Décollage" );
			}
			Application.Quit();
		}
       
        void OnDisable()
        {
            if( VoiceAvailable()>0 )
            {
                FreeVoice();
            }
        }
    }
Placez la DLL dans le dossier windows/system32 ou SysWOW64 pour w7/64 et n'oubliez pas de la diffuser avec votre .exe
Le script est a placer par exemple sur une caméra.

Sujet sur le forum officiel


RealSpeak Solo de Nuance (Scansoft). Voix gratuites

(French - Virgine) http://www.mta.alainlapierre.com/res/RS ... rginie.zip
(German) - Steffi) http://www.mta.alainlapierre.com/res/RS ... Steffi.zip
(Italia) - Silvia) http://www.mta.alainlapierre.com/res/RS ... Silvia.zip
(Spanish) - Isabel) http://www.mta.alainlapierre.com/res/RS ... Isabel.zip
English) - Emily) http://www.mta.alainlapierre.com/res/RS ... hEmily.zip
(Us - Jennifer ) http://udm4.com/Windows/RealSpeak_Solo_Direc-391899

JP
Dernière édition par ZJP le 22 Sep 2010 14:17, édité 1 fois.

Avatar de l’utilisateur
2Mylent
Messages : 14
Inscription : 23 Août 2010 18:35

Re: DLLs pour Unity3D

Message par 2Mylent » 24 Août 2010 02:22

Sur Unity 2.6 Free j'ai un message:
"DllNotFoundException: voice_speaker.dll
VoiceSpeakrr.Start() (at Asset\Scripts\VoiceSpeaker.cs:44)

DllNotFoundException: voice_speaker.dll
VoiceSpeakrr.OnDisable() (at Asset\Scripts\VoiceSpeaker.cs:58)"

(Win7 64bits)

Ma DLL est bien dans le répertoire System32
Par contre par sur la même partition que Unity3D

:?:
2Mylent, alors il faut que je m'occupe l'esprit!
Ma minuscule 2Mylent's store at Renderosity: http://www.renderosity.com/mod/bcs/inde ... ndor=20330

DisTrash
Messages : 229
Inscription : 08 Déc 2009 15:02

Re: DLLs pour Unity3D

Message par DisTrash » 24 Août 2010 19:26

Et ça permet de faire quoi ce script ?

++
;) ;) ;)

Avatar de l’utilisateur
ZJP
Messages : 5745
Inscription : 15 Déc 2009 06:00

Re: DLLs pour Unity3D

Message par ZJP » 25 Août 2010 10:06

2Mylent a écrit :Sur Unity 2.6 Free j'ai un message:
"DllNotFoundException: voice_speaker.dll
VoiceSpeakrr.Start() (at Asset\Scripts\VoiceSpeaker.cs:44)

DllNotFoundException: voice_speaker.dll
VoiceSpeakrr.OnDisable() (at Asset\Scripts\VoiceSpeaker.cs:58)"

(Win7 64bits)

Ma DLL est bien dans le répertoire System32
Par contre par sur la même partition que Unity3D

:?:
Salut,

Bizarre le "VoiceSpeakrr" avec 2 r. :?

@DisTrash
Cela permet de faire du Text to speech. Faire parler tes programmes en utilisant les voix installées sur ton système.

JP

Avatar de l’utilisateur
2Mylent
Messages : 14
Inscription : 23 Août 2010 18:35

Re: DLLs pour Unity3D

Message par 2Mylent » 25 Août 2010 14:59

ZJP a écrit :
2Mylent a écrit :Sur Unity 2.6 Free j'ai un message:
"DllNotFoundException: voice_speaker.dll
VoiceSpeakrr.Start() (at Asset\Scripts\VoiceSpeaker.cs:44)

DllNotFoundException: voice_speaker.dll
VoiceSpeakrr.OnDisable() (at Asset\Scripts\VoiceSpeaker.cs:58)"

(Win7 64bits)

Ma DLL est bien dans le répertoire System32
Par contre par sur la même partition que Unity3D

:?:
Salut,

Bizarre le "VoiceSpeakrr" avec 2 r. :?
JP
Heu c'est une erreur de frappe, j'ai tous resaisi à la mano et comme le message était identique j'ai fais un copié/coller du texte et juste changé le n° de ligne de code (44 et 58) :oops:
2Mylent, alors il faut que je m'occupe l'esprit!
Ma minuscule 2Mylent's store at Renderosity: http://www.renderosity.com/mod/bcs/inde ... ndor=20330

seb7000
Messages : 140
Inscription : 05 Mars 2010 17:51

Re: DLLs pour Unity3D

Message par seb7000 » 13 Fév 2012 16:07

Je déterre un peu les archives, mais je voulais simplement te remercier d'avoir partagé ce dll, l'idée est excellente !
Par contre est-ce qu'entre temps tu aurais trouvé des voix un peu plus convaincantes que celles de windows ?

Après quelques recherches je n'ai rien trouvé de gratuit ou à pris abordable ...

Avatar de l’utilisateur
ZJP
Messages : 5745
Inscription : 15 Déc 2009 06:00

Re: DLLs pour Unity3D

Message par ZJP » 13 Fév 2012 18:04

Nuance RealSpeak Virginie

Procédure pour Windows 7 32Bits. (Pas vérifier sous W7/64)
  • Après téléchargent, décompacter et installer
  • Dans le dossier C :\Windows\SysWOW64\Speech\SpeechUX, double clic sur le fichier sapi.cpl
  • Sélectionner la voix ScanSoft Virginie_Dri40_16kHz
  • Entrer une phrase de test.
  • Click sur [Tester la voix]
  • Click sur [Appliquer]
  • Click sur [OK]
JP

seb7000
Messages : 140
Inscription : 05 Mars 2010 17:51

Re: DLLs pour Unity3D

Message par seb7000 » 13 Fév 2012 18:14

Merci, je vais jeter un coup d'oeil ;)

Avatar de l’utilisateur
ZJP
Messages : 5745
Inscription : 15 Déc 2009 06:00

Re: DLLs pour Unity3D

Message par ZJP » 13 Fév 2012 18:24

Pour les achats, regarde ici : http://nextup.com/TextAloud/SpeechEngine/voices.html
Les compatibles SAPI4 et SAPI5 feront l'affaire.

JP

seb7000
Messages : 140
Inscription : 05 Mars 2010 17:51

Re: DLLs pour Unity3D

Message par seb7000 » 17 Fév 2012 09:33

Merci pour ce nouveau lien :)

Répondre

Revenir vers « Les outils externes »