You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
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.
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");
The text was updated successfully, but these errors were encountered: