Skip to content

feat: migrate google-cloud-speech to librarian (keep helpers)#8648

Open
suztomo wants to merge 2 commits into
googleapis:mainfrom
suztomo:migrate-google-cloud-speech
Open

feat: migrate google-cloud-speech to librarian (keep helpers)#8648
suztomo wants to merge 2 commits into
googleapis:mainfrom
suztomo:migrate-google-cloud-speech

Conversation

@suztomo

@suztomo suztomo commented Jun 15, 2026

Copy link
Copy Markdown
Member

This PR migrates the google-cloud-speech package to use Librarian for code generation, while preserving the custom streamingRecognize helper and its tests to avoid breaking changes and preserve test coverage.

This is a follow-up to the initial attempt in #8635, which removed the helper and tests.

Highlights

  • Enabled Librarian generation for google-cloud-speech by removing skip_generate: true in librarian.yaml.
  • Added keep configuration in librarian.yaml to preserve:
    • src/helpers.ts (custom helper)
    • src/index.ts (mixin logic)
    • test/helpers.test.ts (unit tests)
    • system-test/fixtures/streamingRecognize/input.wav (test fixture)
    • system-test/speech_system_test.js etc. (legacy system tests)
  • Removed OwlBot configuration (.OwlBot.yaml) and other obsolete configs.

Detailed Rationale for keep List

Why is src/helpers.ts kept?

src/helpers.ts contains the custom streamingRecognize helper. In the initial attempt (#8635), this helper was removed to transition to a fully auto-generated client. However, this helper is exposed to users and removing it introduces a major breaking change.

The Breaking Change:
The custom helper wraps the raw gRPC stream. Without it:

  1. Users can no longer pass streamingConfig directly as the first argument to streamingRecognize(config).
  2. The returned stream no longer accepts raw audio buffers directly (e.g. via stream.write(audioBuffer) or .pipe()). Instead, users must write StreamingRecognizeRequest objects directly, wrapping the audio in {audioContent: buffer}.

Keeping src/helpers.ts preserves this helper and avoids these breaking changes.

Why is src/index.ts kept?

src/index.ts contains the runtime mixin logic that injects the helper into the generated clients:

import {ImprovedStreamingClient} from './helpers';
// ...
Object.defineProperty(
  v1.SpeechClient.prototype,
  'streamingRecognize',
  Object.getOwnPropertyDescriptor(
    ImprovedStreamingClient.prototype,
    'streamingRecognize'
  )!
);

If src/index.ts is not in the keep list, Librarian will overwrite it with a default generated index file that only contains standard exports.
Without the mixin logic in src/index.ts, the custom helper in helpers.ts is never bound to the SpeechClient prototype at runtime. Calling client.streamingRecognize() would fail (as the generated method is renamed to _streamingRecognize by librarian.js to avoid conflicts, leaving streamingRecognize undefined).

Why are the system tests and input.wav kept?

We preserve the legacy system tests (system-test/speech_system_test.js, system-test/speech_typescript_system_test.ts, etc.) and the associated test fixture (system-test/fixtures/streamingRecognize/input.wav) to maintain test coverage for the preserved helper. These tests verify the streamingRecognize helper functionality at a system level.

Note: We may delete these legacy system tests later (see Librarian #6377).

Detailed Rationale for Deleted Files

Why was prettier.config.js deleted?

prettier.config.js was deleted because it is redundant.

It previously contained:

module.exports = {
  singleQuote: true,
  trailingComma: 'es5',
};

This is identical to the standard Google TypeScript Style (GTS) config. The monorepo has a root .prettierrc.cjs that extends gts/.prettierrc.json. With this package-level config removed, Prettier will correctly fall back to the root config, ensuring consistent formatting across the entire repository without maintaining redundant local configuration files.

User-facing Changes

None. The custom streamingRecognize helper and its mixin logic are preserved, so behavior is identical to pre-migration.

@suztomo suztomo requested a review from a team as a code owner June 15, 2026 17:02
@suztomo suztomo added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 15, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jun 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the configuration and metadata for the @google-cloud/speech package. Key changes include modifying librarian.yaml to retain specific helper and index files, updating .repo-metadata.json with new API descriptions and documentation links, and removing outdated OwlBot and Prettier configuration files along with several system test files. Additionally, copyright years are updated in helper and test files. There are no review comments, and I have no feedback to provide.

@suztomo

suztomo commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

All checks have passed.

@suztomo

suztomo commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

Superseding #8635

@suztomo suztomo requested a review from shivanee-p June 15, 2026 17:31
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