Skip to content
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

Edge Engine outputs broken wav file #238

Open
FuatW opened this issue Dec 24, 2024 · 1 comment
Open

Edge Engine outputs broken wav file #238

FuatW opened this issue Dec 24, 2024 · 1 comment

Comments

@FuatW
Copy link

FuatW commented Dec 24, 2024

I'm trying to import the audio file generated into unity.

This works with every engine I've tried so far perfectly (SystemEngine, CoquiEngine, GTTSEngine)
But with the Edge engine I'll get this error:

ArgumentException: Frequency in created clip must be greater than 0 UnityEngine.AudioClip.Create (System.String name, System.Int32 lengthSamples, System.Int32 channels, System.Int32 frequency, System.Boolean stream, UnityEngine.AudioClip+PCMReaderCallback pcmreadercallback, UnityEngine.AudioClip+PCMSetPositionCallback pcmsetpositioncallback) (at <c08eccfa13ce4e9da1b670057c106561>:0) UnityEngine.AudioClip.Create (System.String name, System.Int32 lengthSamples, System.Int32 channels, System.Int32 frequency, System.Boolean stream) (at <c08eccfa13ce4e9da1b670057c106561>:0) WavUtility.ToAudioClip (System.Byte[] wavData) (at Assets/Scripts/WavUtility.cs:37) AudioPlayer.LoadAudioClip (System.String path) (at Assets/Scripts/AudioFileMonitor.cs:101) AudioPlayer+<PlayAudioFiles>d__5.MoveNext () (at Assets/Scripts/AudioFileMonitor.cs:50) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <44f3679c53d1477a9c6e72f269e3a3a9>:0)

Also I cannot open the wav file with some applications.

Does anyone know a fix? Thanks in advance.

@KoljaB
Copy link
Owner

KoljaB commented Dec 24, 2024

Edge Engine actually synthesizes MP3 files, not WAV. That might explain the issue you're seeing.

Here’s a quick example that works perfectly for me using RealtimeTTS:

if __name__ == "__main__":
    from RealtimeTTS import TextToAudioStream, EdgeEngine
    import os

    def dummy_generator():
        yield "Hey guys! These here are realtime spoken sentences based on local text synthesis. "
        yield "With a local, neuronal, cloned voice. So every spoken sentence sounds unique."

    print("Starting engines")
    edge_engine = EdgeEngine()
    stream = TextToAudioStream(edge_engine)
    stream.feed(dummy_generator())
    stream.play(output_wavfile=stream.engine.engine_name + "_output.mp3")

The MP3 file gets generated without any errors on my end, and it plays back exactly as expected. Could it be that you're trying to process an MP3 as if it’s a WAV file? That would explain why Unity throws the frequency error and why some apps fail to open the file.

Let me know if this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants