GithubHelp home page GithubHelp logo

Comments (10)

wujingcheng7 avatar wujingcheng7 commented on July 19, 2024 1

I also encountered the same issue, but fortunately, I found the cause and fixed it. The crash here is caused by a null pointer, SherpaOnnxOfflineTtsWrapper.tts == nil, which is due to an incorrect configuration file passed during initialization. It seems that when you added files to the project, you selected "Create groups" in Xcode, which flattened the directory structure. The framework expects to access the directory /demo.app//espeak-ng-data/{target}, but the actual produced directory is /demo.app//{target}. This mismatch caused an error when passing /demo.app//espeak-ng-data as an argument to generate SherpaOnnxOfflineTtsVitsModelConfig, ultimately resulting in SherpaOnnxOfflineTtsWrapper.tts == nil.

My suggestion is to choose "Create folder references" when adding files and to check each path in func createOfflineTts() to ensure they are correct (you can directly call "FileManager.default.fileExists(atPath: path)"). If all paths are correct, the issue should be resolved.

Additionally, be cautious when using the two official demo methods func resourceURL(to path: String) -> String and func getResource(_ forResource: String, _ ofType: String) as they can be conflicting in some cases, where one expects correct input and the other expects incorrect input. You likely encountered this scenario. You should adapt these methods to fit your specific needs by obtaining the correct target path. You can refer to my modifications for guidance.

我也遇到了相同的问题,幸运的是我找到了原因并且修复了它。首先你这里崩溃的原因是空指针导致的,SherpaOnnxOfflineTtsWrapper.tts == nil,这是由于在它在 init 时传入的配置文件有误。你应该是在 add files to project 的时候选择了 “Create groups”,这会导致 XCode 完全打平目录,framework 希望访问的目录是 /demo.app//espeak-ng-data/{target} 但是实际生产的目录是 /demo.app//{target},这就导致当你把 /demo.app//espeak-ng-data 作为传入参数交给 framework 用于生成 SherpaOnnxOfflineTtsVitsModelConfig 时遭遇了错误,并最终导致 SherpaOnnxOfflineTtsWrapper.tts == nil。
所以我的建议是在你 add files 时选择 "Create folder references",并且在func createOfflineTts() 里面检查一下每个 path 是否正确(可以直接调用 "FileManager.default.fileExists(atPath: path)"),如果 path 都是正确的,那么问题就解决了。
此外,需要谨慎使用官方demo 的这两个方法 func resourceURL(to path: String) -> String 和 func getResource(_ forResource: String, _ ofType: String) -> String,在某些情况下这两个方法是互相矛盾的,也就是一个预期正确一个预期错误,你大概率就是遇到了这种情况。你需要结合你自己的实际情况,自己去获取争取的目标 path。这里你可以参考一下我的修改。

image

from sherpa-onnx.

csukuangfj avatar csukuangfj commented on July 19, 2024

Please show the output of

git diff

and post the screenshot of your xcode project files so that we can see what files you have added to the project.

from sherpa-onnx.

hafsalm avatar hafsalm commented on July 19, 2024

Here is the output of git diff. I haven't made any change in the code. Just added the "en_US-amy-low" files to the project.

diff --git a/ios-swiftui/SherpaOnnxTts/SherpaOnnxTts.xcodeproj/project.pbxproj b/ios-swiftui/SherpaOnnxTts/SherpaOnnxTts.xcodeproj/project.pbxproj
index e9ea2c2..2d16d63 100644
--- a/ios-swiftui/SherpaOnnxTts/SherpaOnnxTts.xcodeproj/project.pbxproj
+++ b/ios-swiftui/SherpaOnnxTts/SherpaOnnxTts.xcodeproj/project.pbxproj
@@ -7,6 +7,364 @@
        objects = {
 
 /* Begin PBXBuildFile section */
+               0C6857772BE75995002A7AC6 /* en_US-amy-low.onnx in Resources */ = {isa = PBXBuildFile; fileRef = 0C6855EB2BE75995002A7AC6 /* en_US-amy-low.onnx */; };
------ SKIPPED FOR READABLITLY ---------
sourceTree = "<group>"; };
+               0C6857712BE75995002A7AC6 /* vi_dict */ = {isa = PBXFileReference; lastKnownFileType = file; path = vi_dict; sourceTree = "<group>"; };
+               0C6857722BE75995002A7AC6 /* yue_dict */ = {isa = PBXFileReference; lastKnownFileType = file; path = yue_dict; sourceTree = "<group>"; };
+               0C6857752BE75995002A7AC6 /* tokens.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tokens.txt; path = "../../../vits-piper-en_US-amy-low/tokens.txt"; sourceTree = "<group>"; };
+               0C6857762BE75995002A7AC6 /* en_US-amy-low.onnx.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "en_US-amy-low.onnx.json"; path = "../../../vits-piper-en_US-amy-low/en_US-amy-low.onnx.json"; sourceTree = "<group>"; };
                C917B4E12B0EEF3B005245AC /* SherpaOnnxTts.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SherpaOnnxTts.app; sourceTree = BUILT_PRODUCTS_DIR; };
                C917B4E42B0EEF3B005245AC /* SherpaOnnxTtsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxTtsApp.swift; sourceTree = "<group>"; };
                C917B4E62B0EEF3B005245AC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -42,9 +758,664 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+               0C6855EF2BE75995002A7AC6 /* aav */ = {
+                       isa = PBXGroup;
+                       children = (
+                               0C6855EC2BE75995002A7AC6 /* vi */,
+                               0C6856FA2BE75995002A7AC6 /* zac */,
+                       );
+                       path = "!v";
+                       sourceTree = "<group>";
+               };
+               0C6856FC2BE75995002A7AC6 /* voices */ = {
+                       isa = PBXGroup;
+                       children = (
+                               0C6856FB2BE75995002A7AC6 /* !v */,
+                       );
+                       path = voices;
+                       sourceTree = "<group>";
+               };
+               0C6857732BE75995002A7AC6 /* espeak-ng-data */ = {
+                       isa = PBXGroup;
+                       children = (
+                               0C6856922BE75995002A7AC6 /* lang */,
+                               0C6857722BE75995002A7AC6 /* yue_dict */,
+                       );
+                       name = "espeak-ng-data";
+                       path = "../../../vits-piper-en_US-amy-low/espeak-ng-data";
+                       sourceTree = "<group>";
+               };
                C917B4D82B0EEF3B005245AC = {
                        isa = PBXGroup;
                        children = (
+                               0C6855EB2BE75995002A7AC6 /* en_US-amy-low.onnx */,
                                C9FE9FE82B0F3754009F1003 /* Frameworks */,
@@ -147,8 +1518,366 @@
                        isa = PBXResourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               0C6858BE2BE75996002A7AC6 /* qu_dict in Resources */,
+                               0C6858982BE75996002A7AC6 /* kk_dict in Resources */,
+                               0C6857F22BE75995002A7AC6 /* bs in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -291,6 +2020,7 @@
                                CODE_SIGN_STYLE = Automatic;
                                CURRENT_PROJECT_VERSION = 1;
                                DEVELOPMENT_ASSET_PATHS = "\"SherpaOnnxTts/Preview Content\"";
+                               DEVELOPMENT_TEAM = QSSSXUTZ8W;
                                ENABLE_PREVIEWS = YES;
                                FRAMEWORK_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios";
                                GENERATE_INFOPLIST_FILE = YES;
@@ -306,7 +2036,7 @@
                                );
                                MARKETING_VERSION = 1.0;
                                OTHER_LDFLAGS = "-lc++";
-                               PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTts";
+                               PRODUCT_BUNDLE_IDENTIFIER = com.test.SherpaOnnxTts;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                SWIFT_EMIT_LOC_STRINGS = YES;
                                SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
@@ -323,6 +2053,7 @@
                                CODE_SIGN_STYLE = Automatic;
                                CURRENT_PROJECT_VERSION = 1;
                                DEVELOPMENT_ASSET_PATHS = "\"SherpaOnnxTts/Preview Content\"";
+                               DEVELOPMENT_TEAM = QSSSXUTZ8W;
                                ENABLE_PREVIEWS = YES;
                                FRAMEWORK_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios";
                                GENERATE_INFOPLIST_FILE = YES;
@@ -338,7 +2069,7 @@
                                );
                                MARKETING_VERSION = 1.0;
                                OTHER_LDFLAGS = "-lc++";
-                               PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTts";
+                               PRODUCT_BUNDLE_IDENTIFIER = com.test.SherpaOnnxTts;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                SWIFT_EMIT_LOC_STRINGS = YES;
                                SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";

Here is the xCode project files SS
image

Thank you so much for your help.

from sherpa-onnx.

csukuangfj avatar csukuangfj commented on July 19, 2024

Could you describe how you added espeak-ng-data? Make.sure it is not a symlink.

Could you delete it and add it again?

Check that the reported file.in.the.error log does exist.

from sherpa-onnx.

hafsalm avatar hafsalm commented on July 19, 2024

Here is how i added espeak-ng-data to the project.

  1. Downloaded the model file vits-piper-en_US-amy-low.tar.bz2 from https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
  2. After extraction, from xCode, used the option Add files to 'SherpaOnnxTts' by selecting en_US-amy-low.onnx, en_US-amy-low.onnx.json, tokens.txt and espeak-ng-data folder.

When I check the espeak-ng-data folder, I'm able to see the 'phontab' file inside.

I also tried deleting espeak-ng-data folder reference from xcode and added again. Still the same issue.

Am I taking the right approach to adding the espeak-ng-data folder?

from sherpa-onnx.

csukuangfj avatar csukuangfj commented on July 19, 2024

Could.you use

ls -lh to check the file in the error.log.

Remember to copy and paste the absolute path from.the.error.log.

from sherpa-onnx.

hafsalm avatar hafsalm commented on July 19, 2024

I checked for the file in the log '/private/var/containers/Bundle/Application/32C03D12-4D6E-4296-9192-F7452BBD0A7B/SherpaOnnxTts.app/espeak-ng-data/phontab' does not exist. when I ls -lh the full path, its showing error as No such file or directory.

I also tried removing the espeak-ng-data reference from xcode by deleting it. Still the same error. So I am assuming, the folder reference is not properly added with my steps. Can you pls tell me what is the right approach to adding the espeak-ng-data to the xcode? or something else I'm missing here?

I also tried by downloading the espeak-ng-data directly from https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/espeak-ng-data.tar.bz2.

from sherpa-onnx.

csukuangfj avatar csukuangfj commented on July 19, 2024

Pleasr check the paths in your git diff output.

The../../../ relative path looks suspicious.

from sherpa-onnx.

csukuangfj avatar csukuangfj commented on July 19, 2024

Pleasr check the paths in your git diff output.

The../../../ relative path looks suspicious.

from sherpa-onnx.

hafsalm avatar hafsalm commented on July 19, 2024

The../../../ relative path looks suspicious.

the vits-piper-en_US-amy-low folder is outside the sherpa-onnx and from that location only the en_US-amy-low.onnx file being loaded.

Can you please advise me what is the right way of adding the en_US-amy-low.onnx and its supporting files including the espeak-ng-data folder?

i followed https://www.youtube.com/watch?v=MvePdkuMNJk for getTtsForVCTK and its working perfectly.

from sherpa-onnx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.