Fangjun Kuang
Committed by GitHub

Text-to-speech for iOS (#443)

@@ -67,6 +67,13 @@ swift-api-examples/k2fsa-* @@ -67,6 +67,13 @@ swift-api-examples/k2fsa-*
67 run-*.sh 67 run-*.sh
68 two-pass-*.sh 68 two-pass-*.sh
69 build-* 69 build-*
  70 +
  71 +## User settings
  72 +xcuserdata/
  73 +
  74 +## Xcode 8 and earlier
  75 +*.xcscmblueprint
  76 +*.xccheckout
70 vits-vctk 77 vits-vctk
71 vits-zh-aishell3 78 vits-zh-aishell3
72 jslint.mjs 79 jslint.mjs
  1 +// !$*UTF8*$!
  2 +{
  3 + archiveVersion = 1;
  4 + classes = {
  5 + };
  6 + objectVersion = 56;
  7 + objects = {
  8 +
  9 +/* Begin PBXBuildFile section */
  10 + C917B4E52B0EEF3B005245AC /* SherpaOnnxTtsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C917B4E42B0EEF3B005245AC /* SherpaOnnxTtsApp.swift */; };
  11 + C917B4E72B0EEF3B005245AC /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C917B4E62B0EEF3B005245AC /* ContentView.swift */; };
  12 + C917B4E92B0EEF3C005245AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C917B4E82B0EEF3C005245AC /* Assets.xcassets */; };
  13 + C917B4EC2B0EEF3C005245AC /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C917B4EB2B0EEF3C005245AC /* Preview Assets.xcassets */; };
  14 + C9FE9FE52B0F33CD009F1003 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9FE9FE42B0F33CD009F1003 /* ViewModel.swift */; };
  15 + C9FE9FE72B0F3620009F1003 /* SherpaOnnx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9FE9FE62B0F3620009F1003 /* SherpaOnnx.swift */; };
  16 + C9FE9FEA2B0F3754009F1003 /* sherpa-onnx.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE9FE92B0F3754009F1003 /* sherpa-onnx.xcframework */; };
  17 + C9FE9FEF2B0F3EFB009F1003 /* onnxruntime.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE9FEB2B0F3785009F1003 /* onnxruntime.xcframework */; };
  18 +/* End PBXBuildFile section */
  19 +
  20 +/* Begin PBXFileReference section */
  21 + C917B4E12B0EEF3B005245AC /* SherpaOnnxTts.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SherpaOnnxTts.app; sourceTree = BUILT_PRODUCTS_DIR; };
  22 + C917B4E42B0EEF3B005245AC /* SherpaOnnxTtsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxTtsApp.swift; sourceTree = "<group>"; };
  23 + C917B4E62B0EEF3B005245AC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
  24 + C917B4E82B0EEF3C005245AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
  25 + C917B4EB2B0EEF3C005245AC /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
  26 + C9FE9FE42B0F33CD009F1003 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = "<group>"; };
  27 + C9FE9FE62B0F3620009F1003 /* SherpaOnnx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SherpaOnnx.swift; path = "../../../swift-api-examples/SherpaOnnx.swift"; sourceTree = "<group>"; };
  28 + C9FE9FE92B0F3754009F1003 /* sherpa-onnx.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "sherpa-onnx.xcframework"; path = "../../build-ios/sherpa-onnx.xcframework"; sourceTree = "<group>"; };
  29 + C9FE9FEB2B0F3785009F1003 /* onnxruntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = onnxruntime.xcframework; path = "../../build-ios/ios-onnxruntime/1.16.2/onnxruntime.xcframework"; sourceTree = "<group>"; };
  30 +/* End PBXFileReference section */
  31 +
  32 +/* Begin PBXFrameworksBuildPhase section */
  33 + C917B4DE2B0EEF3B005245AC /* Frameworks */ = {
  34 + isa = PBXFrameworksBuildPhase;
  35 + buildActionMask = 2147483647;
  36 + files = (
  37 + C9FE9FEF2B0F3EFB009F1003 /* onnxruntime.xcframework in Frameworks */,
  38 + C9FE9FEA2B0F3754009F1003 /* sherpa-onnx.xcframework in Frameworks */,
  39 + );
  40 + runOnlyForDeploymentPostprocessing = 0;
  41 + };
  42 +/* End PBXFrameworksBuildPhase section */
  43 +
  44 +/* Begin PBXGroup section */
  45 + C917B4D82B0EEF3B005245AC = {
  46 + isa = PBXGroup;
  47 + children = (
  48 + C917B4E32B0EEF3B005245AC /* SherpaOnnxTts */,
  49 + C917B4E22B0EEF3B005245AC /* Products */,
  50 + C9FE9FE82B0F3754009F1003 /* Frameworks */,
  51 + );
  52 + sourceTree = "<group>";
  53 + };
  54 + C917B4E22B0EEF3B005245AC /* Products */ = {
  55 + isa = PBXGroup;
  56 + children = (
  57 + C917B4E12B0EEF3B005245AC /* SherpaOnnxTts.app */,
  58 + );
  59 + name = Products;
  60 + sourceTree = "<group>";
  61 + };
  62 + C917B4E32B0EEF3B005245AC /* SherpaOnnxTts */ = {
  63 + isa = PBXGroup;
  64 + children = (
  65 + C9FE9FE62B0F3620009F1003 /* SherpaOnnx.swift */,
  66 + C9FE9FE42B0F33CD009F1003 /* ViewModel.swift */,
  67 + C917B4E42B0EEF3B005245AC /* SherpaOnnxTtsApp.swift */,
  68 + C917B4E62B0EEF3B005245AC /* ContentView.swift */,
  69 + C917B4E82B0EEF3C005245AC /* Assets.xcassets */,
  70 + C917B4EA2B0EEF3C005245AC /* Preview Content */,
  71 + );
  72 + path = SherpaOnnxTts;
  73 + sourceTree = "<group>";
  74 + };
  75 + C917B4EA2B0EEF3C005245AC /* Preview Content */ = {
  76 + isa = PBXGroup;
  77 + children = (
  78 + C917B4EB2B0EEF3C005245AC /* Preview Assets.xcassets */,
  79 + );
  80 + path = "Preview Content";
  81 + sourceTree = "<group>";
  82 + };
  83 + C9FE9FE82B0F3754009F1003 /* Frameworks */ = {
  84 + isa = PBXGroup;
  85 + children = (
  86 + C9FE9FEB2B0F3785009F1003 /* onnxruntime.xcframework */,
  87 + C9FE9FE92B0F3754009F1003 /* sherpa-onnx.xcframework */,
  88 + );
  89 + name = Frameworks;
  90 + sourceTree = "<group>";
  91 + };
  92 +/* End PBXGroup section */
  93 +
  94 +/* Begin PBXNativeTarget section */
  95 + C917B4E02B0EEF3B005245AC /* SherpaOnnxTts */ = {
  96 + isa = PBXNativeTarget;
  97 + buildConfigurationList = C917B4EF2B0EEF3C005245AC /* Build configuration list for PBXNativeTarget "SherpaOnnxTts" */;
  98 + buildPhases = (
  99 + C917B4DD2B0EEF3B005245AC /* Sources */,
  100 + C917B4DE2B0EEF3B005245AC /* Frameworks */,
  101 + C917B4DF2B0EEF3B005245AC /* Resources */,
  102 + );
  103 + buildRules = (
  104 + );
  105 + dependencies = (
  106 + );
  107 + name = SherpaOnnxTts;
  108 + productName = SherpaOnnxTts;
  109 + productReference = C917B4E12B0EEF3B005245AC /* SherpaOnnxTts.app */;
  110 + productType = "com.apple.product-type.application";
  111 + };
  112 +/* End PBXNativeTarget section */
  113 +
  114 +/* Begin PBXProject section */
  115 + C917B4D92B0EEF3B005245AC /* Project object */ = {
  116 + isa = PBXProject;
  117 + attributes = {
  118 + BuildIndependentTargetsInParallel = 1;
  119 + LastSwiftUpdateCheck = 1420;
  120 + LastUpgradeCheck = 1420;
  121 + TargetAttributes = {
  122 + C917B4E02B0EEF3B005245AC = {
  123 + CreatedOnToolsVersion = 14.2;
  124 + };
  125 + };
  126 + };
  127 + buildConfigurationList = C917B4DC2B0EEF3B005245AC /* Build configuration list for PBXProject "SherpaOnnxTts" */;
  128 + compatibilityVersion = "Xcode 14.0";
  129 + developmentRegion = en;
  130 + hasScannedForEncodings = 0;
  131 + knownRegions = (
  132 + en,
  133 + Base,
  134 + );
  135 + mainGroup = C917B4D82B0EEF3B005245AC;
  136 + productRefGroup = C917B4E22B0EEF3B005245AC /* Products */;
  137 + projectDirPath = "";
  138 + projectRoot = "";
  139 + targets = (
  140 + C917B4E02B0EEF3B005245AC /* SherpaOnnxTts */,
  141 + );
  142 + };
  143 +/* End PBXProject section */
  144 +
  145 +/* Begin PBXResourcesBuildPhase section */
  146 + C917B4DF2B0EEF3B005245AC /* Resources */ = {
  147 + isa = PBXResourcesBuildPhase;
  148 + buildActionMask = 2147483647;
  149 + files = (
  150 + C917B4EC2B0EEF3C005245AC /* Preview Assets.xcassets in Resources */,
  151 + C917B4E92B0EEF3C005245AC /* Assets.xcassets in Resources */,
  152 + );
  153 + runOnlyForDeploymentPostprocessing = 0;
  154 + };
  155 +/* End PBXResourcesBuildPhase section */
  156 +
  157 +/* Begin PBXSourcesBuildPhase section */
  158 + C917B4DD2B0EEF3B005245AC /* Sources */ = {
  159 + isa = PBXSourcesBuildPhase;
  160 + buildActionMask = 2147483647;
  161 + files = (
  162 + C917B4E72B0EEF3B005245AC /* ContentView.swift in Sources */,
  163 + C9FE9FE72B0F3620009F1003 /* SherpaOnnx.swift in Sources */,
  164 + C9FE9FE52B0F33CD009F1003 /* ViewModel.swift in Sources */,
  165 + C917B4E52B0EEF3B005245AC /* SherpaOnnxTtsApp.swift in Sources */,
  166 + );
  167 + runOnlyForDeploymentPostprocessing = 0;
  168 + };
  169 +/* End PBXSourcesBuildPhase section */
  170 +
  171 +/* Begin XCBuildConfiguration section */
  172 + C917B4ED2B0EEF3C005245AC /* Debug */ = {
  173 + isa = XCBuildConfiguration;
  174 + buildSettings = {
  175 + ALWAYS_SEARCH_USER_PATHS = NO;
  176 + CLANG_ANALYZER_NONNULL = YES;
  177 + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
  178 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
  179 + CLANG_ENABLE_MODULES = YES;
  180 + CLANG_ENABLE_OBJC_ARC = YES;
  181 + CLANG_ENABLE_OBJC_WEAK = YES;
  182 + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
  183 + CLANG_WARN_BOOL_CONVERSION = YES;
  184 + CLANG_WARN_COMMA = YES;
  185 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  186 + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
  187 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  188 + CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
  189 + CLANG_WARN_EMPTY_BODY = YES;
  190 + CLANG_WARN_ENUM_CONVERSION = YES;
  191 + CLANG_WARN_INFINITE_RECURSION = YES;
  192 + CLANG_WARN_INT_CONVERSION = YES;
  193 + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
  194 + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
  195 + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
  196 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  197 + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
  198 + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
  199 + CLANG_WARN_STRICT_PROTOTYPES = YES;
  200 + CLANG_WARN_SUSPICIOUS_MOVE = YES;
  201 + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
  202 + CLANG_WARN_UNREACHABLE_CODE = YES;
  203 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  204 + COPY_PHASE_STRIP = NO;
  205 + DEBUG_INFORMATION_FORMAT = dwarf;
  206 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  207 + ENABLE_TESTABILITY = YES;
  208 + GCC_C_LANGUAGE_STANDARD = gnu11;
  209 + GCC_DYNAMIC_NO_PIC = NO;
  210 + GCC_NO_COMMON_BLOCKS = YES;
  211 + GCC_OPTIMIZATION_LEVEL = 0;
  212 + GCC_PREPROCESSOR_DEFINITIONS = (
  213 + "DEBUG=1",
  214 + "$(inherited)",
  215 + );
  216 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  217 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  218 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  219 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  220 + GCC_WARN_UNUSED_FUNCTION = YES;
  221 + GCC_WARN_UNUSED_VARIABLE = YES;
  222 + IPHONEOS_DEPLOYMENT_TARGET = 16.2;
  223 + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
  224 + MTL_FAST_MATH = YES;
  225 + ONLY_ACTIVE_ARCH = YES;
  226 + SDKROOT = iphoneos;
  227 + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
  228 + SWIFT_OPTIMIZATION_LEVEL = "-Onone";
  229 + };
  230 + name = Debug;
  231 + };
  232 + C917B4EE2B0EEF3C005245AC /* Release */ = {
  233 + isa = XCBuildConfiguration;
  234 + buildSettings = {
  235 + ALWAYS_SEARCH_USER_PATHS = NO;
  236 + CLANG_ANALYZER_NONNULL = YES;
  237 + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
  238 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
  239 + CLANG_ENABLE_MODULES = YES;
  240 + CLANG_ENABLE_OBJC_ARC = YES;
  241 + CLANG_ENABLE_OBJC_WEAK = YES;
  242 + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
  243 + CLANG_WARN_BOOL_CONVERSION = YES;
  244 + CLANG_WARN_COMMA = YES;
  245 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  246 + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
  247 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  248 + CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
  249 + CLANG_WARN_EMPTY_BODY = YES;
  250 + CLANG_WARN_ENUM_CONVERSION = YES;
  251 + CLANG_WARN_INFINITE_RECURSION = YES;
  252 + CLANG_WARN_INT_CONVERSION = YES;
  253 + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
  254 + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
  255 + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
  256 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  257 + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
  258 + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
  259 + CLANG_WARN_STRICT_PROTOTYPES = YES;
  260 + CLANG_WARN_SUSPICIOUS_MOVE = YES;
  261 + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
  262 + CLANG_WARN_UNREACHABLE_CODE = YES;
  263 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  264 + COPY_PHASE_STRIP = NO;
  265 + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
  266 + ENABLE_NS_ASSERTIONS = NO;
  267 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  268 + GCC_C_LANGUAGE_STANDARD = gnu11;
  269 + GCC_NO_COMMON_BLOCKS = YES;
  270 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  271 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  272 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  273 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  274 + GCC_WARN_UNUSED_FUNCTION = YES;
  275 + GCC_WARN_UNUSED_VARIABLE = YES;
  276 + IPHONEOS_DEPLOYMENT_TARGET = 16.2;
  277 + MTL_ENABLE_DEBUG_INFO = NO;
  278 + MTL_FAST_MATH = YES;
  279 + SDKROOT = iphoneos;
  280 + SWIFT_COMPILATION_MODE = wholemodule;
  281 + SWIFT_OPTIMIZATION_LEVEL = "-O";
  282 + VALIDATE_PRODUCT = YES;
  283 + };
  284 + name = Release;
  285 + };
  286 + C917B4F02B0EEF3C005245AC /* Debug */ = {
  287 + isa = XCBuildConfiguration;
  288 + buildSettings = {
  289 + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
  290 + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
  291 + CODE_SIGN_STYLE = Automatic;
  292 + CURRENT_PROJECT_VERSION = 1;
  293 + DEVELOPMENT_ASSET_PATHS = "\"SherpaOnnxTts/Preview Content\"";
  294 + ENABLE_PREVIEWS = YES;
  295 + FRAMEWORK_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios";
  296 + GENERATE_INFOPLIST_FILE = YES;
  297 + HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios/sherpa-onnx.xcframework/Headers";
  298 + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
  299 + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
  300 + INFOPLIST_KEY_UILaunchScreen_Generation = YES;
  301 + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
  302 + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
  303 + LD_RUNPATH_SEARCH_PATHS = (
  304 + "$(inherited)",
  305 + "@executable_path/Frameworks",
  306 + );
  307 + MARKETING_VERSION = 1.0;
  308 + OTHER_LDFLAGS = "-lc++";
  309 + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTts";
  310 + PRODUCT_NAME = "$(TARGET_NAME)";
  311 + SWIFT_EMIT_LOC_STRINGS = YES;
  312 + SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
  313 + SWIFT_VERSION = 5.0;
  314 + TARGETED_DEVICE_FAMILY = "1,2";
  315 + };
  316 + name = Debug;
  317 + };
  318 + C917B4F12B0EEF3C005245AC /* Release */ = {
  319 + isa = XCBuildConfiguration;
  320 + buildSettings = {
  321 + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
  322 + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
  323 + CODE_SIGN_STYLE = Automatic;
  324 + CURRENT_PROJECT_VERSION = 1;
  325 + DEVELOPMENT_ASSET_PATHS = "\"SherpaOnnxTts/Preview Content\"";
  326 + ENABLE_PREVIEWS = YES;
  327 + FRAMEWORK_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios";
  328 + GENERATE_INFOPLIST_FILE = YES;
  329 + HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios/sherpa-onnx.xcframework/Headers";
  330 + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
  331 + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
  332 + INFOPLIST_KEY_UILaunchScreen_Generation = YES;
  333 + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
  334 + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
  335 + LD_RUNPATH_SEARCH_PATHS = (
  336 + "$(inherited)",
  337 + "@executable_path/Frameworks",
  338 + );
  339 + MARKETING_VERSION = 1.0;
  340 + OTHER_LDFLAGS = "-lc++";
  341 + PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTts";
  342 + PRODUCT_NAME = "$(TARGET_NAME)";
  343 + SWIFT_EMIT_LOC_STRINGS = YES;
  344 + SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
  345 + SWIFT_VERSION = 5.0;
  346 + TARGETED_DEVICE_FAMILY = "1,2";
  347 + };
  348 + name = Release;
  349 + };
  350 +/* End XCBuildConfiguration section */
  351 +
  352 +/* Begin XCConfigurationList section */
  353 + C917B4DC2B0EEF3B005245AC /* Build configuration list for PBXProject "SherpaOnnxTts" */ = {
  354 + isa = XCConfigurationList;
  355 + buildConfigurations = (
  356 + C917B4ED2B0EEF3C005245AC /* Debug */,
  357 + C917B4EE2B0EEF3C005245AC /* Release */,
  358 + );
  359 + defaultConfigurationIsVisible = 0;
  360 + defaultConfigurationName = Release;
  361 + };
  362 + C917B4EF2B0EEF3C005245AC /* Build configuration list for PBXNativeTarget "SherpaOnnxTts" */ = {
  363 + isa = XCConfigurationList;
  364 + buildConfigurations = (
  365 + C917B4F02B0EEF3C005245AC /* Debug */,
  366 + C917B4F12B0EEF3C005245AC /* Release */,
  367 + );
  368 + defaultConfigurationIsVisible = 0;
  369 + defaultConfigurationName = Release;
  370 + };
  371 +/* End XCConfigurationList section */
  372 + };
  373 + rootObject = C917B4D92B0EEF3B005245AC /* Project object */;
  374 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Workspace
  3 + version = "1.0">
  4 + <FileRef
  5 + location = "self:">
  6 + </FileRef>
  7 +</Workspace>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>IDEDidComputeMac32BitWarning</key>
  6 + <true/>
  7 +</dict>
  8 +</plist>
  1 +{
  2 + "colors" : [
  3 + {
  4 + "idiom" : "universal"
  5 + }
  6 + ],
  7 + "info" : {
  8 + "author" : "xcode",
  9 + "version" : 1
  10 + }
  11 +}
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "platform" : "ios",
  6 + "size" : "1024x1024"
  7 + }
  8 + ],
  9 + "info" : {
  10 + "author" : "xcode",
  11 + "version" : 1
  12 + }
  13 +}
  1 +{
  2 + "info" : {
  3 + "author" : "xcode",
  4 + "version" : 1
  5 + }
  6 +}
  1 +//
  2 +// ContentView.swift
  3 +// SherpaOnnxTts
  4 +//
  5 +// Created by fangjun on 2023/11/23.
  6 +//
  7 +// Speech-to-text with Next-gen Kaldi on iOS without Internet connection
  8 +
  9 +import SwiftUI
  10 +import AVFoundation
  11 +
  12 +struct ContentView: View {
  13 + @State private var sid = "0"
  14 + @State private var speed = 1.0
  15 + @State private var text = ""
  16 + @State private var showAlert = false
  17 + @State var filename: URL = NSURL() as URL
  18 + @State var audioPlayer: AVAudioPlayer!
  19 +
  20 + private var tts = createOfflineTts()
  21 +
  22 + var body: some View {
  23 +
  24 + VStack(alignment: .leading) {
  25 + HStack {
  26 + Spacer()
  27 + Text("Next-gen Kaldi: TTS").font(.title)
  28 + Spacer()
  29 + }
  30 + HStack{
  31 + Text("Speaker ID")
  32 + TextField("Please input a speaker ID", text: $sid).textFieldStyle(.roundedBorder)
  33 + .keyboardType(.numberPad)
  34 + }
  35 + HStack{
  36 + Text("Speed \(String(format: "%.1f", speed))")
  37 + .padding(.trailing)
  38 + Slider(value: $speed, in: 0.5...2.0, step: 0.1) {
  39 + Text("Speech speed")
  40 + }
  41 + }
  42 +
  43 + Text("Please input your text below").padding([.trailing, .top, .bottom])
  44 +
  45 + TextEditor(text: $text)
  46 + .font(.body)
  47 + .opacity(self.text.isEmpty ? 0.25 : 1)
  48 + .disableAutocorrection(true)
  49 + .border(Color.black)
  50 +
  51 + Spacer()
  52 + HStack {
  53 + Spacer()
  54 + Button(action: {
  55 + let speakerId = Int(self.sid) ?? 0
  56 + let t = self.text.trimmingCharacters(in: .whitespacesAndNewlines)
  57 + if t.isEmpty {
  58 + self.showAlert = true
  59 + return
  60 + }
  61 +
  62 + let audio = tts.generate(text: t, sid: speakerId, speed: Float(self.speed))
  63 + if self.filename.absoluteString.isEmpty {
  64 + let tempDirectoryURL = NSURL.fileURL(withPath: NSTemporaryDirectory(), isDirectory: true)
  65 + self.filename = tempDirectoryURL.appendingPathComponent("test.wav")
  66 + }
  67 +
  68 + let ret = audio.save(filename: filename.path)
  69 +
  70 + self.audioPlayer = try! AVAudioPlayer(contentsOf: filename)
  71 + self.audioPlayer.play()
  72 + }) {
  73 + Text("Generate")
  74 + }.alert(isPresented: $showAlert) {
  75 + Alert(title: Text("Empty text"), message: Text("Please input your text before clicking the Generate button"))
  76 + }
  77 + Spacer()
  78 + Button (action: {
  79 + self.audioPlayer.play()
  80 + }) {
  81 + Text("Play")
  82 + }.disabled(filename.absoluteString.isEmpty)
  83 + Spacer()
  84 + }
  85 + Spacer()
  86 + }
  87 + .padding()
  88 + }
  89 +}
  90 +
  91 +struct ContentView_Previews: PreviewProvider {
  92 + static var previews: some View {
  93 + ContentView()
  94 + }
  95 +}
  1 +{
  2 + "info" : {
  3 + "author" : "xcode",
  4 + "version" : 1
  5 + }
  6 +}
  1 +//
  2 +// SherpaOnnxTtsApp.swift
  3 +// SherpaOnnxTts
  4 +//
  5 +// Created by fangjun on 2023/11/23.
  6 +//
  7 +
  8 +import SwiftUI
  9 +
  10 +@main
  11 +struct SherpaOnnxTtsApp: App {
  12 + var body: some Scene {
  13 + WindowGroup {
  14 + ContentView()
  15 + }
  16 + }
  17 +}
  1 +//
  2 +// ViewModel.swift
  3 +// SherpaOnnxTts
  4 +//
  5 +// Created by fangjun on 2023/11/23.
  6 +//
  7 +
  8 +import Foundation
  9 +
  10 +func getResource(_ forResource: String, _ ofType: String) -> String {
  11 + let path = Bundle.main.path(forResource: forResource, ofType: ofType)
  12 + precondition(
  13 + path != nil,
  14 + "\(forResource).\(ofType) does not exist!\n" + "Remember to change \n"
  15 + + " Build Phases -> Copy Bundle Resources\n" + "to add it!"
  16 + )
  17 + return path!
  18 +}
  19 +
  20 +/// Please refer to
  21 +/// https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/index.html
  22 +/// to download pre-trained models
  23 +
  24 +func getTtsForVCTK() -> SherpaOnnxOfflineTtsWrapper {
  25 + // See the following link
  26 + // https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/vits.html#vctk-english-multi-speaker-109-speakers
  27 +
  28 + // vits-vctk.onnx
  29 + let model = getResource("vits-vctk", "onnx")
  30 +
  31 + // lexicon.txt
  32 + let lexicon = getResource("lexicon", "txt")
  33 +
  34 + // tokens.txt
  35 + let tokens = getResource("tokens", "txt")
  36 +
  37 + let vits = sherpaOnnxOfflineTtsVitsModelConfig(model: model, lexicon: lexicon, tokens: tokens)
  38 + let modelConfig = sherpaOnnxOfflineTtsModelConfig(vits: vits)
  39 + var config = sherpaOnnxOfflineTtsConfig(model: modelConfig)
  40 + return SherpaOnnxOfflineTtsWrapper(config: &config)
  41 +}
  42 +
  43 +func getTtsForAishell3() -> SherpaOnnxOfflineTtsWrapper {
  44 + // See the following link
  45 + // https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/vits.html#vits-model-aishell3
  46 +
  47 + // vits-vctk.onnx
  48 + let model = getResource("vits-aishell3", "onnx")
  49 +
  50 + // lexicon.txt
  51 + let lexicon = getResource("lexicon", "txt")
  52 +
  53 + // tokens.txt
  54 + let tokens = getResource("tokens", "txt")
  55 +
  56 + let vits = sherpaOnnxOfflineTtsVitsModelConfig(model: model, lexicon: lexicon, tokens: tokens)
  57 + let modelConfig = sherpaOnnxOfflineTtsModelConfig(vits: vits)
  58 + var config = sherpaOnnxOfflineTtsConfig(model: modelConfig)
  59 + return SherpaOnnxOfflineTtsWrapper(config: &config)
  60 +}
  61 +
  62 +func createOfflineTts() -> SherpaOnnxOfflineTtsWrapper {
  63 + return getTtsForVCTK()
  64 +
  65 + // return getTtsForAishell3()
  66 +
  67 + // please add more models on need by following the above two examples
  68 +}
@@ -650,8 +650,8 @@ class SherpaOnnxGeneratedAudioWrapper { @@ -650,8 +650,8 @@ class SherpaOnnxGeneratedAudioWrapper {
650 } 650 }
651 } 651 }
652 652
653 - func save(filename: String) {  
654 - SherpaOnnxWriteWave(audio.pointee.samples, n, sampleRate, toCPointer(filename)) 653 + func save(filename: String) -> Int32 {
  654 + return SherpaOnnxWriteWave(audio.pointee.samples, n, sampleRate, toCPointer(filename))
655 } 655 }
656 } 656 }
657 657