-
-
Notifications
You must be signed in to change notification settings - Fork 13
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Cannot create FMOD::Sound instance for clip "" (FMOD error: Error loading file. ) #89
Comments
Need a code snippet for repro steps |
It is generating mp3 or PCM? |
This is my ElevenLabsManager.cs script: using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using ElevenLabs;
using System.Threading.Tasks;
using System.Threading;
using Utilities.Async;
public class ElevenLabsManager : MonoBehaviour
{
// Singleton instance
public static ElevenLabsManager Instance { get; private set; }
private string elevenLabsAPIKey;
private ElevenLabsClient api;
private void Awake()
{
// Ensure there's only one instance of AIManager
if (Instance == null)
{
Instance = this;
//DontDestroyOnLoad(gameObject); // Optional: Keep this instance between scene loads
}
else
{
Destroy(gameObject);
}
}
void Start()
{
// Get the API key set in the user's environment variables
elevenLabsAPIKey = Environment.GetEnvironmentVariable("ELEVEN_LABS_API_KEY", EnvironmentVariableTarget.User);
Debug.Log(elevenLabsAPIKey);
if (!string.IsNullOrEmpty(elevenLabsAPIKey))
{
Debug.Log("API Key found: " + elevenLabsAPIKey);
// Use the API key in your requests or other logic
}
else
{
Debug.LogError("API Key not found!");
}
// Initialize the ElevenLabs API Client
api = new ElevenLabsClient(elevenLabsAPIKey);
if (api == null)
{
Debug.LogError("ElevenLabsClient could not be initialized.");
}
}
// Function to generate an audio clip from text and voiceId
public async Task<AudioClip> GenerateAudioClip(string text, string voiceId)
{
try
{
// Fetch the voice using the voiceId
var voice = await api.VoicesEndpoint.GetVoiceAsync(voiceId);
if (voice == null)
{
Debug.LogError("Voice not found with the given voiceId.");
return null;
}
// Fetch the default voice settings
var defaultVoiceSettings = await api.VoicesEndpoint.GetDefaultVoiceSettingsAsync();
if (defaultVoiceSettings == null)
{
Debug.LogError("Default voice settings could not be retrieved.");
return null;
}
// Generate the AudioClip using the TextToSpeech API
var voiceClip = await api.TextToSpeechEndpoint.TextToSpeechAsync(text, voice, defaultVoiceSettings);
return voiceClip.AudioClip;
}
catch (System.Exception ex)
{
Debug.LogError($"Error generating audio clip: {ex.Message}");
return null;
}
}
}
I am making calls to it like so: AIUser.cs // Text to speech- I accidently named this function SpeechToText. Will need to fix this, but inform others to change their function name in their scripts.
public async void SpeechToText(string text)
{
AudioClip clip;
if (characterData.usingOnlineTTS == false)
{
clip = await AIManager.Instance.GetTextToSpeech(text, characterData.speakerID);
}
else
{
clip = await AIManager.Instance.GetElevenLabsAudioClip(text, characterData.elevenLabsModelID);
}
audioSource.clip = clip;
audioSource.loop = false;
audioSource.Play();
} AIManager.cs // *** ONLINE TEXT TO SPEECH FUNCTIONS ***
// Function to get audio clip from ElevenLabs using ElevenLabsManager
public async Task<AudioClip> GetElevenLabsAudioClip(string text, string voiceId)
{
try
{
// Use the ElevenLabsManager's GenerateAudioClip function to get the audio clip
AudioClip clip = await ElevenLabsManager.Instance.GenerateAudioClip(text, voiceId);
return clip;
}
catch (System.Exception ex)
{
Debug.LogError($"Error in GetElevenLabsAudioClip: {ex.Message}");
return null;
}
} AIUser -> AIManager -> ElevenLabsManager I greatly appreciate you responding so quickly! |
What happens when you run the sample scene? |
Usually this should only happen in this context #35 |
The sample scene seems to run with no issues. I noticed you used audioSource.PlayOneShot(), and so I changed the end of my AIUser function to this: // Text to speech- I accidently named this function SpeechToText. Will need to fix this, but inform others to change their function name in their scripts.
public async void SpeechToText(string text)
{
AudioClip clip;
if (characterData.usingOnlineTTS == false)
{
clip = await AIManager.Instance.GetTextToSpeech(text, characterData.speakerID);
}
else
{
clip = await AIManager.Instance.GetElevenLabsAudioClip(text, characterData.elevenLabsModelID);
}
//audioSource.clip = clip;
//audioSource.loop = false;
audioSource.PlayOneShot(clip);
} And I seem to be getting no errors now. Could that possibly be it!? I only changed the last three lines of that function. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Bug Report
Overview
To Reproduce
Steps to reproduce the behavior:
I simply made a normal Text to Speech request using the library.
The first request I make works just fine, but any continued requests throw this error. When I stop and start the game again, it works the first time.
The text was updated successfully, but these errors were encountered: