Пример #1
0
        private void SayPersonSpatial(string who, string message, Vector3 position, AssignedVoice av, bool spatial)
        {
            // Fix up any chat-ese symbols and pronounciations.
            message = subs.FixExpressions(message);
            if (message == "")
            {
                return;
            }

            // Distinguish speech from self-narration.
            if (message.StartsWith("/me"))
            {
                SayAction(
                    who,
                    message.Substring(3),
                    position,
                    av,
                    spatial);
            }
            else
            {
                Say(
                    who,
                    message,
                    position,
                    av,
                    spatial,
                    BeepType.None);
            }
        }
Пример #2
0
        /// <summary>
        /// Look up or assign a voice with a gender hint.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        internal AssignedVoice VoiceFor(UUID id, bool makeOne)
        {
            // First choice is a voice already matched.
            if (assignedVoices.ContainsKey(id))
            {
                return(assignedVoices[id]);
            }

            // Then see if pre-assigned.
            if (PreAssigned(id))
            {
                return(assignedVoices[id]);
            }

            // Make one up.
            if (!makeOne)
            {
                return(null);
            }

            AssignedVoice assigned = PickRandomVoice(id);

            assignedVoices[id] = assigned;
            return(assigned);
        }
Пример #3
0
        /// <summary>
        /// Say something as a named person or object at a location.
        /// </summary>
        /// <param name="who">Name of person speaking</param>
        /// <param name="what">What they said</param>
        /// <param name="where">Where they were standing when they said it</param>
        /// <param name="v">The voice they use</param>
        internal void Say(
            string who,
            string what,
            Vector3 where,
            AssignedVoice v)
        {
            if (queue == null)
            {
                return;
            }

            // Create queue entry from the information.
            QueuedSpeech e = new QueuedSpeech(
                subs.FixExpressions(who),
                subs.FixExpressions(what),
                where,
                v,
                false);

            // Put that on the queue and wake up the background thread.
            lock (queue)
            {
                queue.Enqueue(e);
                Monitor.Pulse(queue);
            }
        }
Пример #4
0
        internal void Say(
            string who,
            string what,
            Vector3 where,
            AssignedVoice v,
            bool doRotate,
            BeepType beep)
        {
            if (queue == null)
            {
                return;
            }

            QueuedSpeech e = new QueuedSpeech(
                subs.FixExpressions(who),
                subs.FixExpressions(what),
                where, v, false, doRotate, beep);

            // Put that on the queue and wake up the background thread.
            lock (queue)
            {
                queue.Enqueue(e);
                Monitor.Pulse(queue);
            }
        }
Пример #5
0
        /// <summary>
        /// Save or update a permanent voice assignment.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="v"></param>
        private void SaveAssignment(string name, AssignedVoice v)
        {
            // Definition is the voice name in single quotes followed
            // by optional modifiers.
            string definition = "'" + v.root.Name + "'";

            switch (v.pitchModification)
            {
            case 0: break;

            case -1:    definition += " low";   break;

            case +1:    definition += " high";  break;
            }

            switch (v.rateModification)
            {
            case 0: break;

            case -1:    definition += " slow";   break;

            case +1:    definition += " fast";  break;
            }

            // Update the configuration file.
            configVoices[name] = new OSDString(definition);
            control.SaveSpeechSettings();
        }
Пример #6
0
        /// <summary>
        /// Possible gender reassignment based on new information.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="info"></param>
        internal void CheckGender(UUID id, Environment.People.AvatarInfo info)
        {
            // If no voice assigned yet, do not worry.
            if (!assignedVoices.ContainsKey(id))
            {
                return;
            }

            AssignedVoice v = assignedVoices[id];
            // A voice is assigned.  If gender matches, do nothing.
            bool isMale = (info.gender > 0);

            if (v.Male == isMale)
            {
                return;
            }

            // Make a new voice of the correct type, if possible.
            if (!GenderAvailable(isMale))
            {
                return;
            }

            // A voice of the correct gender is available, so pick one.
            v = PickRandomVoice(id);
            assignedVoices[id] = v;
        }
Пример #7
0
 /// <summary>
 /// Constructor for common beepless and spatialized utterances.
 /// </summary>
 /// <param name="who"></param>
 /// <param name="what"></param>
 /// <param name="where"></param>
 /// <param name="v"></param>
 /// <param name="action"></param>
 internal QueuedSpeech(string who, string what,
    Vector3 where, AssignedVoice v, bool action)
 {
     speaker = who;
     message = what;
     position = where;
     voice = v;
     isAction = action;
     isSpatial = true;
 }
Пример #8
0
 /// <summary>
 /// Constructor for common beepless and spatialized utterances.
 /// </summary>
 /// <param name="who"></param>
 /// <param name="what"></param>
 /// <param name="where"></param>
 /// <param name="v"></param>
 /// <param name="action"></param>
 internal QueuedSpeech(string who, string what,
                       Vector3 where, AssignedVoice v, bool action)
 {
     speaker   = who;
     message   = what;
     position  = where;
     voice     = v;
     isAction  = action;
     isSpatial = true;
 }
Пример #9
0
        /// <summary>
        /// Pick a one-time voice for a name.
        /// </summary>
        /// <param name="avName"></param>
        /// <returns></returns>
        /// <remarks>This is used just for System and Object voices.</remarks>
        internal AssignedVoice VoiceFor(string avName)
        {
            AssignedVoice v = PreAssigned(avName);

            if (v != null)
            {
                return(v);
            }

            return(PickRandomVoice());
        }
Пример #10
0
 internal QueuedSpeech(string who, string what,
                       Vector3 where, AssignedVoice v, bool action,
                       bool doRotate, BeepType b)
 {
     speaker   = who;
     message   = what;
     position  = where;
     voice     = v;
     isAction  = action;
     isSpatial = doRotate;
     beep      = b;
 }
Пример #11
0
        /// <summary>
        /// Assign system voices the first time.
        /// </summary>
        private void FirstCheck()
        {
            if (!firstTime || control.osLayer == null)
            {
                return;
            }

            firstTime = false;
            // Initialize the library of installed voices.
            SystemVoice = voices.VoiceFor("System");
            ObjectVoice = voices.VoiceFor("Object");
        }
Пример #12
0
 internal QueuedSpeech(string who, string what,
     Vector3 where, AssignedVoice v, bool action,
     bool doRotate, BeepType b)
 {
     speaker = who;
     message = what;
     position = where;
     voice = v;
     isAction = action;
     isSpatial = doRotate;
     beep = b;
 }
Пример #13
0
        /// <summary>
        /// Force a particular voice assignment.
        /// </summary>
        /// <param name="v"></param>
        /// <param name="aName"></param>
        /// <param name="id"></param>
        internal void AssignVoice(AssignedVoice v, string aName, UUID id)
        {
            if (id != UUID.Zero && assignedVoices.ContainsKey(id))
            {
                assignedVoices.Remove(id);
            }

            // Update the live dictionary for this session
            assignedVoices[id] = v;

            // Update the preferences file for future sessions
            SaveAssignment(aName, v);
        }
Пример #14
0
        /// <summary>
        /// Test if an avatar has a pre-selected name.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        internal bool PreAssigned(UUID id)
        {
            // Need the avatar name.
            string avName = control.instance.Names.Get(id);

            if (avName == null)
            {
                return(false);
            }

            AssignedVoice av = PreAssigned(avName);

            if (av == null)
            {
                return(false);
            }

            assignedVoices[id] = av;
            return(true);
        }
Пример #15
0
        /// <summary>
        /// Queue up an action to say.
        /// </summary>
        /// <param name="who"></param>
        /// <param name="what"></param>
        /// <param name="where"></param>
        /// <param name="v"></param>
        internal void SayAction(
            string who,
            string what,
            Vector3 where,
            AssignedVoice v,
            bool spatial)
        {
            if (queue == null)
            {
                return;
            }

            QueuedSpeech e = new QueuedSpeech(
                subs.FixExpressions(who),
                subs.FixExpressions(what),
                where, v, true, spatial, BeepType.None);

            lock (queue)
            {
                queue.Enqueue(e);
                Monitor.Pulse(queue);
            }
        }
Пример #16
0
        /// <summary>
        /// Save or update a permanent voice assignment.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="v"></param>
        private void SaveAssignment(string name, AssignedVoice v)
        {
            // Definition is the voice name in single quotes followed
            // by optional modifiers.
            string definition = "'" + v.root.Name + "'";
            switch (v.pitchModification)
            {
                case 0: break;
                case -1:    definition += " low";   break;
                case +1:    definition += " high";  break;
            }

            switch (v.rateModification)
            {
                case 0: break;
                case -1:    definition += " slow";   break;
                case +1:    definition += " fast";  break;
            }

            // Update the configuration file.
            configVoices[name] = new OSDString(definition);
            control.SaveSpeechSettings();
        }
Пример #17
0
        /// <summary>
        /// Queue up an action to say.
        /// </summary>
        /// <param name="who"></param>
        /// <param name="what"></param>
        /// <param name="where"></param>
        /// <param name="v"></param>
        internal void SayAction(
            string who,
            string what,
            Vector3 where,
            AssignedVoice v,
            bool spatial)
        {
            if (queue == null) return;

            QueuedSpeech e = new QueuedSpeech(
                subs.FixExpressions(who),
                subs.FixExpressions(what),
                where, v, true, spatial, BeepType.None);
            lock (queue)
            {
                queue.Enqueue(e);
                Monitor.Pulse(queue);
            }
        }
Пример #18
0
 /// <summary>
 /// Speak for another avatar.
 /// </summary>
 /// <param name="who"></param>
 /// <param name="message"></param>
 /// <param name="position"></param>
 /// <param name="av"></param>
 /// <remarks>This includes special processing for /me and other chat
 /// conventions.</remarks>
 internal void SayPerson(string who, string message, Vector3 position, AssignedVoice av)
 {
     SayPersonSpatial(who, message, position, av, true);
 }
Пример #19
0
        /// <summary>
        /// Assign system voices the first time.
        /// </summary>
        private void FirstCheck()
        {
            if (!firstTime || control.osLayer==null) return;

            firstTime = false;
            // Initialize the library of installed voices.
            SystemVoice = voices.VoiceFor("System");
            ObjectVoice = voices.VoiceFor("Object");
        }
Пример #20
0
        private void SayPersonSpatial( string who, string message, Vector3 position, AssignedVoice av, bool spatial )
        {
            // Fix up any chat-ese symbols and pronounciations.
            message = subs.FixExpressions(message);
            if (message == "") return;

            // Distinguish speech from self-narration.
            if (message.StartsWith("/me"))
            {
                SayAction(
                    who,
                    message.Substring(3),
                    position,
                    av,
                    spatial);
            }
            else
            {
                Say(
                    who,
                    message,
                    position,
                    av,
                    spatial,
                    BeepType.None);
            }
        }
Пример #21
0
 /// <summary>
 /// Speak for another avatar.
 /// </summary>
 /// <param name="who"></param>
 /// <param name="message"></param>
 /// <param name="position"></param>
 /// <param name="av"></param>
 /// <remarks>This includes special processing for /me and other chat
 /// conventions.</remarks>
 internal void SayPerson(string who, string message, Vector3 position, AssignedVoice av)
 {
     SayPersonSpatial(who, message, position, av, true);
 }
Пример #22
0
        internal void Say(
            string who,
            string what,
            Vector3 where,
            AssignedVoice v,
            bool doRotate,
            BeepType beep)
        {
            if (queue == null) return;

            QueuedSpeech e = new QueuedSpeech(
                subs.FixExpressions(who),
                subs.FixExpressions(what),
                where, v, false, doRotate, beep);

            // Put that on the queue and wake up the background thread.
            lock (queue)
            {
                queue.Enqueue(e);
                Monitor.Pulse(queue);
            }
        }
Пример #23
0
        /// <summary>
        /// Force a particular voice assignment.
        /// </summary>
        /// <param name="v"></param>
        /// <param name="aName"></param>
        /// <param name="id"></param>
        internal void AssignVoice(AssignedVoice v, string aName, UUID id)
        {
            if (id != UUID.Zero && assignedVoices.ContainsKey(id))
                assignedVoices.Remove(id);

            // Update the live dictionary for this session
            assignedVoices[id] = v;

            // Update the preferences file for future sessions
            SaveAssignment(aName, v);
        }
Пример #24
0
        private void StartSpeech(AssignedVoice vb, string outputfile)
        {
            WinAvailableVoice wv = (WinAvailableVoice)vb.root;

            // Find the best audio format to use for this voice.
            System.Collections.ObjectModel.ReadOnlyCollection<SpeechAudioFormatInfo> formats =
                wv.winVoice.VoiceInfo.SupportedAudioFormats;

            format = formats.FirstOrDefault();

            if (format == null)
            {
                // The voice did not tell us its parameters, so we pick some.
                format = new SpeechAudioFormatInfo(
                    16000,      // Samples per second
                    AudioBitsPerSample.Sixteen,
                    AudioChannel.Mono);
            }

            // First set up to synthesize the message into a WAV file.
            mstream = new FileStream(outputfile, FileMode.Create, FileAccess.Write);

            syn.SetOutputToWaveStream(mstream);

            pb = new PromptBuilder();
            mainStyle = new PromptStyle();
            //            mainStyle.Volume = promptVol;
            syn.SelectVoice(wv.winVoice.VoiceInfo.Name);
            pb.StartStyle(mainStyle);
        }
Пример #25
0
        /// <summary>
        /// Say something as a named person or object at a location.
        /// </summary>
        /// <param name="who">Name of person speaking</param>
        /// <param name="what">What they said</param>
        /// <param name="where">Where they were standing when they said it</param>
        /// <param name="v">The voice they use</param>
        internal void Say(
            string who,
            string what,
            Vector3 where,
            AssignedVoice v)
        {
            if (queue == null) return;

            // Create queue entry from the information.
            QueuedSpeech e = new QueuedSpeech(
                subs.FixExpressions(who),
                subs.FixExpressions(what),
                where,
                v,
                false);

            // Put that on the queue and wake up the background thread.
            lock (queue)
            {
                queue.Enqueue(e);
                Monitor.Pulse(queue);
            }
        }