VAUTextToSpeechSignalSource.cs 1.13 KB
Newer Older
1 2 3 4 5 6 7
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VAUTextToSpeechSignalSource : VAUSignalSource
{
    public string Name; // Versatile name
8 9

    [Tooltip("Text which should be read out.")]
10 11 12 13 14 15 16 17 18 19
    public string Text = "hi there, my name is rachel. virtual acoustics is a real-time auralization framework for scientific research in Virtual Reality created by the institute of technical acoustics, RWTH aachen university. thank you for testing the VA unity C sharp scripts for controlling a VA server.";
    public bool DirectPlayback = false;

    private string _TextIdentifier = "";

    void Awake()
    {
        if (!VAUAdapter.VA.IsConnected())
            return;

20
        _ID = VAUAdapter.VA.CreateSignalSourceTextToSpeech(Name);
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    }

    void Start()
    {
        VAUAdapter.VA.TextToSpeechPrepareText(_ID, _TextIdentifier, Text);
        if (DirectPlayback)
            VAUAdapter.VA.TextToSpeechPlaySpeech(_ID, _TextIdentifier);
    }

    private void Update()
    {
        
    }

    void OnDestroy()
    {
        if (_ID.Length > 0)
            VAUAdapter.VA.DeleteSignalSource(_ID);
    }
}