Skip to content

Fix AutoDetectSourceLangConfig API Misspellings; add backward-compatible alias and tests#164

Merged
rhurey merged 1 commit into
microsoft:masterfrom
mohamed-zaki-coding:feature/autodetect-api-fix
Mar 4, 2026
Merged

Fix AutoDetectSourceLangConfig API Misspellings; add backward-compatible alias and tests#164
rhurey merged 1 commit into
microsoft:masterfrom
mohamed-zaki-coding:feature/autodetect-api-fix

Conversation

@mohamed-zaki-coding
Copy link
Copy Markdown
Contributor

@mohamed-zaki-coding mohamed-zaki-coding commented Feb 25, 2026

Fix AutoDetectSourceLangConfig API Misspellings

Problem

Two public API constructors in the Go Speech SDK have a spelling error — Fom instead of From:

Misspelled Name Corrected Name
NewSpeechRecognizerFomAutoDetectSourceLangConfig NewSpeechRecognizerFromAutoDetectSourceLangConfig
NewSpeechSynthesizerFomAutoDetectSourceLangConfig NewSpeechSynthesizerFromAutoDetectSourceLangConfig

These functions also lacked tests (recognizer) and samples (both).

Changes

API Fix (backward-compatible)

  • speech/speech_recognizer.go — Renamed NewSpeechRecognizerFomAutoDetectSourceLangConfig to NewSpeechRecognizerFromAutoDetectSourceLangConfig. Added a deprecated alias under the old name that delegates to the corrected function.
  • speech/speech_synthesizer.go — Renamed NewSpeechSynthesizerFomAutoDetectSourceLangConfig to NewSpeechSynthesizerFromAutoDetectSourceLangConfig. Added a deprecated alias under the old name that delegates to the corrected function.

New Tests

  • speech/speech_recognizer_test.go — Added TestRecognitionWithLanguageAutoDetection: creates a recognizer via NewSpeechRecognizerFromAutoDetectSourceLangConfig with en-US/de-DE, recognizes from a WAV file, validates the result reason and text.
  • speech/speech_synthesizer_test.go — Updated existing TestSynthesisWithLanguageAutoDetection to use the corrected API name. Minor formatting fix (operator spacing).

New Samples

  • samples/recognizer/auto_detect.go — New sample RecognizeOnceFromAutoDetectSourceLangConfig demonstrating speech recognition with auto-detect source language.
  • samples/synthesizer/auto_detect.go — New sample SynthesisFromAutoDetectSourceLangConfig demonstrating speech synthesis with auto-detect source language (open range).
  • samples/main.go — Registered both new samples in the sample map.

Backward Compatibility

The old misspelled function names are preserved as deprecated aliases. Existing code using NewSpeechRecognizerFomAutoDetectSourceLangConfig or NewSpeechSynthesizerFomAutoDetectSourceLangConfig will continue to compile and work. The // Deprecated: comment will surface warnings in IDEs and go doc.

How to Use

langConfig, _ := speech.NewAutoDetectSourceLanguageConfigFromLanguages([]string{"en-US", "de-DE"})
recognizer, _ := speech.NewSpeechRecognizerFromAutoDetectSourceLangConfig(cfg, langConfig, audioCfg)
// Deprecated alias (still works, but use the new name):
recognizer, _ := speech.NewSpeechRecognizerFomAutoDetectSourceLangConfig(cfg, langConfig, audioCfg)
langConfig, _ := speech.NewAutoDetectSourceLanguageConfigFromOpenRange()
synthesizer, _ := speech.NewSpeechSynthesizerFromAutoDetectSourceLangConfig(cfg, langConfig, nil)
// Deprecated alias (still works, but use the new name):
synthesizer, _ := speech.NewSpeechSynthesizerFomAutoDetectSourceLangConfig(cfg, langConfig, nil)

The // Deprecated: comment is present on the old names, so go doc and IDEs will surface the warning automatically.

Testing

  • go build ./... — ✅ PASS
  • go vet ./...⚠️ known upstream warnings (unsafe.Pointer & unkeyed OperationOutcome literals). Unrelated to this change.
  • go test ./speech/ -run "TestRecognitionWithLanguageAutoDetection" -v -timeout 30s — ✅ PASS (0.65s)
  • go test ./speech/ -run "TestSynthesisWithLanguageAutoDetection" -v -timeout 30s — ✅ PASS (0.42s)

Tests require SPEECH_SUBSCRIPTION_KEY and SPEECH_SUBSCRIPTION_REGION env vars and the test_files/turn_on_the_lamp.wav asset.

@mohamed-zaki-coding mohamed-zaki-coding changed the title Fix AutoDetect API spelling (Fom -> From) with deprecated aliases Fix Go AutoDetectSourceLangConfig API misspellings and lacks tests/samples Feb 25, 2026
@mohamed-zaki-coding mohamed-zaki-coding changed the title Fix Go AutoDetectSourceLangConfig API misspellings and lacks tests/samples Fix AutoDetectSourceLangConfig typo; add backward-compatible alias and tests Feb 25, 2026
@mohamed-zaki-coding mohamed-zaki-coding changed the title Fix AutoDetectSourceLangConfig typo; add backward-compatible alias and tests Fix AutoDetectSourceLangConfig API Misspellings; add backward-compatible alias and tests Feb 25, 2026
@rhurey rhurey merged commit 6e44543 into microsoft:master Mar 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants