Compare commits

..

No commits in common. "543fb0512336693cdb4c6ff8154ee43bdae40d37" and "778dc0ee644457d9fbd085168788c85103e47b30" have entirely different histories.

11 changed files with 55 additions and 27 deletions

View File

@ -766,6 +766,7 @@ Tree("26_Castello_Castelli_di_Bellinzona_Castelli_Bot_Interaktion") {
BTC.Run("MediaPlayer.VIDEOS.CastelliBotInterak_F1") BTC.Run("MediaPlayer.VIDEOS.CastelliBotInterak_F1")
BTC.Run("MediaPlayer.VIDEOS.CastelliBotInterak_FIdle02") BTC.Run("MediaPlayer.VIDEOS.CastelliBotInterak_FIdle02")
BTC.SetSpeechRecognitionLanguage("de-DE") // TODO: muss geloescht werden am Ende
BTC.StartChatbotConversation() BTC.StartChatbotConversation()
BTC.ChatbotConversationEnded() BTC.ChatbotConversationEnded()
BTC.SpeechOutputEnded() BTC.SpeechOutputEnded()

View File

@ -1032,12 +1032,12 @@ public class BTC : MonoBehaviour {
{ {
if (Task.getState == NodeState.FirstRun) if (Task.getState == NodeState.FirstRun)
{ {
string languageCode = "it-IT"; string languageCode = "de-DE";
string instructions = "Rispondi sempre in italiano. Rispondi in lingua colloquiale al livelli di competenza A2 di quadro comune europeo di riferimento per la conoscenza delle lingue."; string instructions = "Antworte immer auf Deutsch.";
string context = "Sei un essere onnisciente che risponde esclusivamente a domande sulla cultura e la storia del Cantone Ticino e dei Castelli di Bellinzona. Parla <Ciao, cosa vuoi sapere? Sono unintelligenza artificiale>. Rispondi sempre nel modo più conciso possibile. Suddividi le domande in passaggi più piccoli e sviluppale. Chiedi se hanno capito tutto. La conversazione ha inizio."; string context = "Du bist ein allwissendes Wesen, welches ausschliesslich Fragen zu Astronomie beantwortet. Sag <Hallo was möchtest du zu Astronomie wissen?>. Antworte immer so kurz wie möglich. Das Gespräch started jetzt.";
int maxRoundTrips = 5; int maxRoundTrips = 5;
float maxSilenceBeforeTimeOut = 10; float maxSilenceBeforeTimeOut = 10;
string outroText = $"Grazie mille, la conversazione è finita."; string outroText = $"Vielen Dank, das Gespräch ist nun beendet";
_onConversationInitiatedEventTriggered = false; _onConversationInitiatedEventTriggered = false;
_speechMng.StartConversation(languageCode, instructions, context, maxRoundTrips, maxSilenceBeforeTimeOut, outroText); _speechMng.StartConversation(languageCode, instructions, context, maxRoundTrips, maxSilenceBeforeTimeOut, outroText);

View File

@ -6413,7 +6413,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: "Szene w\xE4hlen\r" m_text: "Level w\xE4hlen\r"
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 0d97ed6259f90444b8da67a4e5872245, type: 2} m_fontAsset: {fileID: 11400000, guid: 0d97ed6259f90444b8da67a4e5872245, type: 2}
m_sharedMaterial: {fileID: -2574710329927910322, guid: 0d97ed6259f90444b8da67a4e5872245, type: 2} m_sharedMaterial: {fileID: -2574710329927910322, guid: 0d97ed6259f90444b8da67a4e5872245, type: 2}

View File

@ -2267,7 +2267,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!4 &187118496494279981 --- !u!4 &187118496494279981
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2676,7 +2676,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: v. 2025.09.1601 m_text: v. 2024.09.1601
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}

View File

@ -126,8 +126,13 @@ public class ConversationService : MonoBehaviour
#region Events #region Events
private void subscribeToEvents() private async void subscribeToEvents()
{ {
while (vaim == null)
{
await System.Threading.Tasks.Task.Delay(10);
}
vaim.SpeechRecognitionService.OnPartialTranscriptionChangedEvent += this.onPartialTranscriptionChanged; vaim.SpeechRecognitionService.OnPartialTranscriptionChangedEvent += this.onPartialTranscriptionChanged;
vaim.SpeechRecognitionService.OnFullTranscriptionChangedEvent += this.onFullTranscriptionChangedEvent; vaim.SpeechRecognitionService.OnFullTranscriptionChangedEvent += this.onFullTranscriptionChangedEvent;
@ -236,7 +241,6 @@ public class ConversationService : MonoBehaviour
public async void StartConversation(string _languageCode, string _instructions, string _context, int _maxRoundtrips, float _maxSilenceBeforeTimeOut, string _outroText) public async void StartConversation(string _languageCode, string _instructions, string _context, int _maxRoundtrips, float _maxSilenceBeforeTimeOut, string _outroText)
{ {
this.logIfInDebugMode($"Starting new conversation"); this.logIfInDebugMode($"Starting new conversation");
ViaggioAIManager.Instance.soundEffectsEnabled = false;
this.languageCode = _languageCode; this.languageCode = _languageCode;
this.instructions = _instructions; this.instructions = _instructions;
@ -261,8 +265,7 @@ public class ConversationService : MonoBehaviour
vaim.SpeechRecognitionService.StopListening(); vaim.SpeechRecognitionService.StopListening();
this.openAIServices_Conversation.Stop(); this.openAIServices_Conversation.Stop();
this.ConversationState = EConversationState.NotStarted; this.ConversationState = EConversationState.NotStarted;
ViaggioAIManager.Instance.soundEffectsEnabled = true;
} }
#endregion #endregion
@ -359,13 +362,13 @@ public class ConversationService : MonoBehaviour
{ {
this.logIfInDebugMode("Stopping conversation"); this.logIfInDebugMode("Stopping conversation");
this.OnConversationEndedEvent?.Invoke(this, $"Conversation stopped"); this.OnConversationEndedEvent?.Invoke(this, $"Conversation stopped");
if (timeOut)
{
vaim.SpeechSynthesizerService.Synthesize(this.outroText, this.languageCode);
}
if (timeOut)
{
vaim.SpeechSynthesizerService.Synthesize(this.outroText, this.languageCode);
}
this.ConversationState = EConversationState.Ended; this.ConversationState = EConversationState.Ended;
vaim.StopConversation(); vaim.StopConversation();

View File

@ -101,8 +101,13 @@ public class IntentRecognitionService : MonoBehaviour
#region Private Events #region Private Events
private void subscribeToEvents() private async void subscribeToEvents()
{ {
while (vaim == null)
{
await System.Threading.Tasks.Task.Delay(10);
}
vaim.OnViaggioAIStateChangedEvent += this.onViaggioAIStateChanged; vaim.OnViaggioAIStateChangedEvent += this.onViaggioAIStateChanged;
vaim.SpeechRecognitionService.OnFullTranscriptionChangedEvent += this.onFullTranscriptionChanged; vaim.SpeechRecognitionService.OnFullTranscriptionChangedEvent += this.onFullTranscriptionChanged;
@ -188,8 +193,13 @@ public class IntentRecognitionService : MonoBehaviour
#region Private Functions #region Private Functions
private void updateOpenAIServiceState() private async void updateOpenAIServiceState()
{ {
while (vaim == null)
{
await System.Threading.Tasks.Task.Delay(10);
}
bool newIsEnabled = vaim.ViaggioAIState == EViaggioAIState.IntentRecognition; bool newIsEnabled = vaim.ViaggioAIState == EViaggioAIState.IntentRecognition;
this.openAIServices_IntentRecognizer.enabled = newIsEnabled; this.openAIServices_IntentRecognizer.enabled = newIsEnabled;

View File

@ -214,10 +214,9 @@ public class SpeechRecognitionService : MonoBehaviour
lock (threadLocker) lock (threadLocker)
{ {
this.SpeechRecognitionState = ESpeechRecognitionState.Listening; this.SpeechRecognitionState = ESpeechRecognitionState.Listening;
} }
vaim.PlayAudioIfEnabled(this.startedListeningClip); vaim.PlayAudioIfEnabled(this.startedListeningClip);
recognizer.SpeechStartDetected += this.speechRecognizer_SpeechStartDetected; recognizer.SpeechStartDetected += this.speechRecognizer_SpeechStartDetected;
recognizer.Recognizing += this.speechRecognizer_Recognizing; recognizer.Recognizing += this.speechRecognizer_Recognizing;

View File

@ -55,7 +55,7 @@ public class ControllerInputEventHandler : MonoBehaviour
#region Private Functions #region Private Functions
private void checkForInput() private void checkForInput()
{ {
return; return;
} }

View File

@ -28,7 +28,7 @@ public class ViaggioAIManager : MonoBehaviour
private bool debugModeIsActive; private bool debugModeIsActive;
[SerializeField] [SerializeField]
public bool soundEffectsEnabled; private bool soundEffectsEnabled;
[Header("Scene Objects")] [Header("Scene Objects")]
[SerializeField] [SerializeField]
@ -115,13 +115,28 @@ public class ViaggioAIManager : MonoBehaviour
void OnEnable() void OnEnable()
{ {
this.subscribeToEvents();
this.initWithDelay(); this.initWithDelay();
} }
void OnDisable()
{
this.unsubscribeFromEvents();
}
#endregion #endregion
#region Private Events #region Private Events
private void subscribeToEvents()
{
}
private void unsubscribeFromEvents()
{
}
#endregion #endregion
#region Public Events #region Public Events