Skip to content

Commit

Permalink
refactor: rewrite BingLanguageVoice with Swift by Jerry23011
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Jan 17, 2024
1 parent 029a7d8 commit 63729d6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 51 deletions.
10 changes: 4 additions & 6 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
0309E1ED292B439A00AFB76A /* EZTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EC292B439A00AFB76A /* EZTextView.m */; };
0309E1F0292B4A5E00AFB76A /* NSView+EZGetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */; };
0309E1F4292BD6A100AFB76A /* EZQueryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1F3292BD6A100AFB76A /* EZQueryModel.m */; };
030DB2612B56CC6500E27DEA /* BingLanguageVoice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 030DB2602B56CC6500E27DEA /* BingLanguageVoice.swift */; };
0310C8272A94F5DF00B1D81E /* apple-dictionary.html in Resources */ = {isa = PBXBuildFile; fileRef = 0310C8262A94EFA100B1D81E /* apple-dictionary.html */; };
0313F8702AD5577400A5CFB0 /* EasydictTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0313F86F2AD5577400A5CFB0 /* EasydictTests.m */; };
031DBD792AE01E130071CF85 /* easydict in Resources */ = {isa = PBXBuildFile; fileRef = 031DBD782AE01E130071CF85 /* easydict */; };
Expand Down Expand Up @@ -66,7 +67,6 @@
037852B329583F5200D0E2CF /* EZServiceCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 037852B229583F5200D0E2CF /* EZServiceCell.m */; };
037852B629588EDE00D0E2CF /* EZCustomTableRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 037852B529588EDE00D0E2CF /* EZCustomTableRowView.m */; };
037852B9295D49F900D0E2CF /* EZTableRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 037852B8295D49F900D0E2CF /* EZTableRowView.m */; };
037BEFCD2A98FDF700D0F17F /* EZBingLanguageVoice.m in Sources */ = {isa = PBXBuildFile; fileRef = 037BEFCC2A98FDF700D0F17F /* EZBingLanguageVoice.m */; };
037E006D2B3DC098006491C6 /* EZOpenAIService+EZPromptMessages.m in Sources */ = {isa = PBXBuildFile; fileRef = 03CF27FA2B3A787900E19B57 /* EZOpenAIService+EZPromptMessages.m */; };
038030952B4106800009230C /* CocoaLumberjack in Frameworks */ = {isa = PBXBuildFile; productRef = 038030942B4106800009230C /* CocoaLumberjack */; };
038030972B4106800009230C /* CocoaLumberjackSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 038030962B4106800009230C /* CocoaLumberjackSwift */; };
Expand Down Expand Up @@ -325,6 +325,7 @@
0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSView+EZGetViewController.m"; sourceTree = "<group>"; };
0309E1F2292BD6A100AFB76A /* EZQueryModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZQueryModel.h; sourceTree = "<group>"; };
0309E1F3292BD6A100AFB76A /* EZQueryModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZQueryModel.m; sourceTree = "<group>"; };
030DB2602B56CC6500E27DEA /* BingLanguageVoice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BingLanguageVoice.swift; sourceTree = "<group>"; };
0310C8262A94EFA100B1D81E /* apple-dictionary.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-dictionary.html"; sourceTree = "<group>"; };
0313F86D2AD5577400A5CFB0 /* EasydictTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EasydictTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0313F86F2AD5577400A5CFB0 /* EasydictTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EasydictTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -414,8 +415,6 @@
037852B529588EDE00D0E2CF /* EZCustomTableRowView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZCustomTableRowView.m; sourceTree = "<group>"; };
037852B7295D49F900D0E2CF /* EZTableRowView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZTableRowView.h; sourceTree = "<group>"; };
037852B8295D49F900D0E2CF /* EZTableRowView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZTableRowView.m; sourceTree = "<group>"; };
037BEFCB2A98FDF700D0F17F /* EZBingLanguageVoice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZBingLanguageVoice.h; sourceTree = "<group>"; };
037BEFCC2A98FDF700D0F17F /* EZBingLanguageVoice.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZBingLanguageVoice.m; sourceTree = "<group>"; };
03839141292FBE120009828C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
03839142292FBE120009828C /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
03839143292FBE120009828C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2091,8 +2090,7 @@
6295DE302A84D82E006145F4 /* EZBingTranslateModel.m */,
6295DE322A84EF76006145F4 /* EZBingLookupModel.h */,
6295DE332A84EF76006145F4 /* EZBingLookupModel.m */,
037BEFCB2A98FDF700D0F17F /* EZBingLanguageVoice.h */,
037BEFCC2A98FDF700D0F17F /* EZBingLanguageVoice.m */,
030DB2602B56CC6500E27DEA /* BingLanguageVoice.swift */,
03F639932AA6CFBB009B9914 /* EZBingConfig.h */,
03F639942AA6CFBB009B9914 /* EZBingConfig.m */,
);
Expand Down Expand Up @@ -2586,7 +2584,6 @@
03991158292927E000E1B06D /* EZTitlebar.m in Sources */,
03D8A65C2A433B4100D9A968 /* EZConfiguration+EZUserData.m in Sources */,
03BD282229486CF200F5891A /* EZBlueTextButton.m in Sources */,
037BEFCD2A98FDF700D0F17F /* EZBingLanguageVoice.m in Sources */,
03BDA7C22A26DA280079D04F /* NSString+Indenter.m in Sources */,
03542A462937B4C300C34C33 /* EZBaiduTranslateResponse.m in Sources */,
0309E1F0292B4A5E00AFB76A /* NSView+EZGetViewController.m in Sources */,
Expand Down Expand Up @@ -2722,6 +2719,7 @@
0333FDA62A035D5700891515 /* NSString+EZChineseText.m in Sources */,
03E02A222924E77100A10260 /* EZMenuItemManager.m in Sources */,
039D119929D5E26300C93F46 /* EZAudioUtils.m in Sources */,
030DB2612B56CC6500E27DEA /* BingLanguageVoice.swift in Sources */,
EA9943F22B5358BF00EE7B97 /* LanguageExtensions.swift in Sources */,
03B0231729231FA6001C7E63 /* Snip.m in Sources */,
03BFFC6E295FE59C004E033E /* EZQueryResult+EZYoudaoDictModel.m in Sources */,
Expand Down
26 changes: 26 additions & 0 deletions Easydict/Feature/Service/Bing/BingLanguageVoice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// BingLanguageVoice.swift
// Easydict
//
// Created by Jerry on 2023-10-14.
// Copyright © 2023 izual. All rights reserved.
//

import Foundation

// Docs: https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/language-support?tabs=tts

@objc(EZBingLanguageVoice)
class BingLanguageVoice: NSObject {
@objc var lang: String // BCP-47, en-US
@objc var voiceName: String // en-US-JennyNeural

init(lang: String, voiceName: String) {
self.lang = lang
self.voiceName = voiceName
}

@objc class func voice(withLanguage language: String, voiceName: String) -> BingLanguageVoice {
BingLanguageVoice(lang: language, voiceName: voiceName)
}
}
24 changes: 0 additions & 24 deletions Easydict/Feature/Service/Bing/EZBingLanguageVoice.h

This file was deleted.

20 changes: 0 additions & 20 deletions Easydict/Feature/Service/Bing/EZBingLanguageVoice.m

This file was deleted.

2 changes: 1 addition & 1 deletion Easydict/Feature/Service/Bing/EZBingRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#import "EZBingRequest.h"
#import "EZError.h"
#import "EZBingLanguageVoice.h"
#import "NSString+EZRegex.h"
#import "Easydict-Swift.h"

static NSString *const kAudioMIMEType = @"audio/mpeg";
static NSString *const kBingConfigKey = @"kBingConfigKey";
Expand Down

0 comments on commit 63729d6

Please sign in to comment.