Why can't I control an Apple MacOS Speech Synthesis audio device with slider values?

I am working on enabling Apple audio device for speech synthesis (works only on macOS, not iOS) in AudioKit, and I created the AKSpeechSynthesizer class (originally created by wangchou in this pull request ) and the demo project , which are available in the AudioKit division.

My project is very similar to this Cocoa speech synthesis example , but in this project the variable speed can vary and vary smoothly between a low number of words per minute (40) to a large number (300 ish). However, my project starts with a default rate of 175, and any change slows down the speed to a workaround - unless you change it to 350, then it goes very fast.

I don’t see what I am doing differently than in this example, since both projects rely on

SetSpeechProperty(speechChannel, kSpeechRateProperty, newRate as NSNumber?)

to set the speed.

Here is my implementation and working one .

The biggest difference is that my synthesizer is set up as an audio unit, while I think the working example just uses the default output for the speaker.

(pitch) (pitchMod) , , , , .

- , ? .

!

+6
1

, , , , .

CocoaSpeechSynthesis , . , 333, 333.3, .

, -, , .

, - - , , , 3 SpeechSynthesizer:

diff --git a/AudioKit/Common/Nodes/Generators/Speech Synthesizer/AKSpeechSynthesizer.swift b/AudioKit/Common/Nodes/Generators/Speech Synthesizer/AKSpeechSynthesizer.swift
index 81286b8fb..324966e13 100644
--- a/AudioKit/Common/Nodes/Generators/Speech Synthesizer/AKSpeechSynthesizer.swift 
+++ b/AudioKit/Common/Nodes/Generators/Speech Synthesizer/AKSpeechSynthesizer.swift 
@@ -47,7 +47,7 @@ open class AKSpeechSynthesizer: AKNode {
                return
            }
            AKLog("Trying to set new rate")
-            let _ = SetSpeechProperty(speechChannel, kSpeechRateProperty, newRate as NSNumber?)
+            let _ = SetSpeechProperty(speechChannel, kSpeechRateProperty, newRate.rounded() as NSNumber?)
        }
    }

@@ -70,7 +70,7 @@ open class AKSpeechSynthesizer: AKNode {
                return
            }
            AKLog("Trying to set new freq")
-            let _ = SetSpeechProperty(speechChannel, kSpeechPitchBaseProperty, newFrequency as NSNumber?)
+            let _ = SetSpeechProperty(speechChannel, kSpeechPitchBaseProperty, newFrequency.rounded() as NSNumber?)
        }
    }

@@ -93,7 +93,7 @@ open class AKSpeechSynthesizer: AKNode {
                return
            }
            AKLog("Trying to set new modulation")
-            let _ = SetSpeechProperty(speechChannel, kSpeechPitchModProperty, newModulation as NSNumber?)
+            let _ = SetSpeechProperty(speechChannel, kSpeechPitchModProperty, newModulation.rounded() as NSNumber?)
        }
    }

3 Swift.

+3

Source: https://habr.com/ru/post/1695792/


All Articles