Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

For anyone trying to get this to work #9

Open
clonzeh opened this issue Nov 15, 2023 · 0 comments
Open

For anyone trying to get this to work #9

clonzeh opened this issue Nov 15, 2023 · 0 comments

Comments

@clonzeh
Copy link

clonzeh commented Nov 15, 2023

Follow the install steps.

This fix was posted in another bug report, i'm just putting it here and combining all the findings for you.

Inside the folder:
C:\Users\%user%\Documents\YourProject\Library\PackageCache\com.github.asus4.tflite@df752d930b\Runtime
open the file called Interpreter.cs I found this file by using visual studio's Find in Files and searching for: SetInputTensorData and then rightclicking the Interperter.cs tab and copying the file location

Find and edit these methods and change them to match the following:
public void SetInputTensorData(int inputTensorIndex, Array inputTensorData) { GCHandle tensorDataHandle = GCHandle.Alloc(inputTensorData, GCHandleType.Pinned); //if (!inputDataHandles.TryGetValue(inputTensorIndex, out GCHandle tensorDataHandle)) //{ // tensorDataHandle = GCHandle.Alloc(inputTensorData, GCHandleType.Pinned); // inputDataHandles.Add(inputTensorIndex, tensorDataHandle); //} IntPtr tensorDataPtr = tensorDataHandle.AddrOfPinnedObject(); TfLiteTensor tensor = TfLiteInterpreterGetInputTensor(interpreter, inputTensorIndex); ThrowIfError(TfLiteTensorCopyFromBuffer(tensor, tensorDataPtr, Buffer.ByteLength(inputTensorData))); tensorDataHandle.Free(); }
AND
public void GetOutputTensorData(int outputTensorIndex, Array outputTensorData) { GCHandle tensorDataHandle = GCHandle.Alloc(outputTensorData, GCHandleType.Pinned); //if (!outputDataHandles.TryGetValue(outputTensorIndex, out GCHandle tensorDataHandle)) //{ // tensorDataHandle = GCHandle.Alloc(outputTensorData, GCHandleType.Pinned); // outputDataHandles.Add(outputTensorIndex, tensorDataHandle); //} IntPtr tensorDataPtr = tensorDataHandle.AddrOfPinnedObject(); TfLiteTensor tensor = TfLiteInterpreterGetOutputTensor(interpreter, outputTensorIndex); ThrowIfError(TfLiteTensorCopyToBuffer(tensor, tensorDataPtr, Buffer.ByteLength(outputTensorData))); tensorDataHandle.Free(); }

Now create a gameobject to hold the TextToSpeech.cs script.
Add an AudioSource component to the object... assign it to the script.

Assign the other variables to the script from the streamingassets folder:
https://i.imgur.com/AFdnTPs.png

Note: You might need to copy and paste the speech_mapper file from your StreamingAssets folder into your project Assets folder.

Now make your own script and put it on the same gameobject which run:
GetComponent<TextToSpeech>().Speak("hello this is a test");

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

No branches or pull requests

1 participant