Fixes for iOS 17. Updated the log events. Also, it seems the final update from the speech recognizer is now empty so ignore an empty result in the final result.

This commit is contained in:
Jeremy Rand 2023-09-25 19:54:23 -04:00
parent 237310dd0f
commit bdf7a85895
7 changed files with 25 additions and 38 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -601,6 +601,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.halcyontouch.ListenerGS; PRODUCT_BUNDLE_IDENTIFIER = com.halcyontouch.ListenerGS;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES; SUPPORTS_MACCATALYST = YES;
@ -628,6 +629,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.halcyontouch.ListenerGS; PRODUCT_BUNDLE_IDENTIFIER = com.halcyontouch.ListenerGS;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES; SUPPORTS_MACCATALYST = YES;

View File

@ -17,21 +17,6 @@
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
<dict> <dict>
<key>9D5155EE26A1EF7B0075EBC7</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>9D5155FF26A1EF7C0075EBC7</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>9D51560A26A1EF7C0075EBC7</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>9D62FC5F27C494D700AEE01F</key> <key>9D62FC5F27C494D700AEE01F</key>
<dict> <dict>
<key>primary</key> <key>primary</key>

View File

@ -104,7 +104,7 @@ class GSConnection : ObservableObject {
} }
if (!legalTransition) { if (!legalTransition) {
logger.error("Illegal requested state transition from \(oldState) to \(newState)") logger.error("Illegal requested state transition from \(oldState, privacy: .public) to \(newState, privacy: .public)")
errorOccurred(title: "Bad State Change", message: "Illegal state transition from \(oldState) to \(newState)") errorOccurred(title: "Bad State Change", message: "Illegal state transition from \(oldState) to \(newState)")
} else { } else {
state = newState state = newState
@ -126,14 +126,14 @@ class GSConnection : ObservableObject {
private func connectionSuccessful() private func connectionSuccessful()
{ {
changeState(newState:.connected) changeState(newState:.connected)
logger.debug("Connected to \(self.destination)") logger.debug("Connected to \(self.destination, privacy: .public)")
} }
func connect(destination : String) { func connect(destination : String) {
self.destination = destination self.destination = destination
changeState(newState: .connecting) changeState(newState: .connecting)
readQueue.addOperation { [weak self, destination] in readQueue.addOperation { [weak self, destination] in
self?.logger.debug("Attempting to connect to \(destination)") self?.logger.debug("Attempting to connect to \(destination, privacy: .public)")
let client = TCPClient(address: destination, port: Int32(GSConnection.port)) let client = TCPClient(address: destination, port: Int32(GSConnection.port))
switch client.connect(timeout: 10) { switch client.connect(timeout: 10) {
case .success: case .success:
@ -143,7 +143,7 @@ class GSConnection : ObservableObject {
} }
case .failure(let error): case .failure(let error):
client.close() client.close()
self?.logger.error("Failed to connect to \(destination): \(String(describing: error))") self?.logger.error("Failed to connect to \(destination, privacy: .public): \(String(describing: error), privacy: .public)")
self?.mainQueue.addOperation { self?.mainQueue.addOperation {
self?.connectionFailed() self?.connectionFailed()
} }
@ -171,13 +171,13 @@ class GSConnection : ObservableObject {
self.trySend() self.trySend()
} }
} else { } else {
self.logger.error("Unexpected message on socket from \(destination)") self.logger.error("Unexpected message on socket from \(destination, privacy: .public)")
self.errorOccurred(title: "Protocol Error", message: "Unexpected message from the GS") self.errorOccurred(title: "Protocol Error", message: "Unexpected message from the GS")
break break
} }
} }
catch { catch {
self.logger.error("Unable to unpack message on socket from \(destination)") self.logger.error("Unable to unpack message on socket from \(destination, privacy: .public)")
self.errorOccurred(title: "Protocol Error", message: "Unexpected message from the GS") self.errorOccurred(title: "Protocol Error", message: "Unexpected message from the GS")
break break
} }
@ -230,7 +230,7 @@ class GSConnection : ObservableObject {
case .success: case .success:
break break
case .failure(let error): case .failure(let error):
self.logger.error("Unable to send header: \(String(describing: error))") self.logger.error("Unable to send header: \(String(describing: error), privacy: .public)")
return false return false
} }
@ -319,14 +319,14 @@ class GSConnection : ObservableObject {
case .success: case .success:
switch (client.send(data: bytes)) { switch (client.send(data: bytes)) {
case .success: case .success:
logger.debug("Sent text \"\(stringToSend)\"") logger.debug("Sent text \"\(stringToSend, privacy: .public)\"")
break break
case .failure(let error): case .failure(let error):
mainQueue.addOperation { mainQueue.addOperation {
self.errorOccurred(title: "Write Error", message: "Unable to send text to the GS") self.errorOccurred(title: "Write Error", message: "Unable to send text to the GS")
self.disconnect() self.disconnect()
} }
logger.error("Failed to send text: \(String(describing: error))") logger.error("Failed to send text: \(String(describing: error), privacy: .public)")
return false return false
} }
case .failure(let error): case .failure(let error):
@ -334,7 +334,7 @@ class GSConnection : ObservableObject {
self.errorOccurred(title: "Write Error", message: "Unable to send text to the GS") self.errorOccurred(title: "Write Error", message: "Unable to send text to the GS")
self.disconnect() self.disconnect()
} }
logger.error("Failed to send text: \(String(describing: error))") logger.error("Failed to send text: \(String(describing: error), privacy: .public)")
} }
} }
return true return true

View File

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0</string> <string>1.0.1</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>794</string> <string>807</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string> <string>public.app-category.utilities</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -82,7 +82,7 @@ class SpeechForwarder : SpeechForwarderProtocol {
// Configure the microphone input. // Configure the microphone input.
let inputFormat = inputNode.outputFormat(forBus: 0) let inputFormat = inputNode.outputFormat(forBus: 0)
let speechFormat = recognitionRequest.nativeAudioFormat let speechFormat = recognitionRequest.nativeAudioFormat
logger.debug("Recording format \(inputFormat), speech format \(speechFormat)") logger.debug("Recording format \(inputFormat, privacy: .public), speech format \(speechFormat, privacy: .public)")
var formatConverter: AVAudioConverter? var formatConverter: AVAudioConverter?
if (!inputFormat.isEqual(speechFormat)) { if (!inputFormat.isEqual(speechFormat)) {
formatConverter = AVAudioConverter(from:inputFormat, to: speechFormat) formatConverter = AVAudioConverter(from:inputFormat, to: speechFormat)
@ -114,17 +114,17 @@ class SpeechForwarder : SpeechForwarderProtocol {
recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequest) { [weak connection] result, error in recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequest) { [weak connection] result, error in
var isFinal = false var isFinal = false
if let result = result {
// Update the text view with the results.
OperationQueue.main.addOperation {
guard let connection = connection else { return }
connection.set(text: result.bestTranscription.formattedString)
}
isFinal = result.isFinal
}
if error != nil { if error != nil {
self.logger.error("Error from recognizer: \(String(describing: error))") self.logger.error("Error from recognizer: \(String(describing: error), privacy:.public)")
} else if let result = result {
isFinal = result.isFinal
if !isFinal || result.bestTranscription.formattedString != "" {
// Update the text view with the results.
OperationQueue.main.addOperation {
guard let connection = connection else { return }
connection.set(text: result.bestTranscription.formattedString)
}
}
} }
if error != nil || isFinal { if error != nil || isFinal {