Chirp: Model ucapan universal

Chirp adalah model speech-to-text generasi berikutnya dari Google. Merepresentasikan puncak dari penelitian selama bertahun-tahun, versi pertama Chirp kini tersedia untuk Speech-to-Text. Kami bermaksud meningkatkan dan memperluas Chirp ke lebih banyak bahasa dan domain. Untuk mengetahui detailnya, lihat makalah kami, Google USM.

Kami melatih model Chirp dengan arsitektur yang berbeda dari model ucapan kami saat ini. Satu model menyatukan data dari beberapa bahasa. Namun, pengguna tetap menentukan model akan mengenali ucapan dalam bahasa yang dipilih. Chirp tidak mendukung beberapa fitur Google Speech yang dimiliki model lain. Lihat Dukungan dan batasan fitur untuk mengetahui daftar lengkap.

ID model

Chirp tersedia di Speech-to-Text API v2. Anda dapat menggunakannya seperti model lainnya.

ID model untuk Chirp adalah: chirp.

Anda dapat menentukan model ini dalam permintaan pengenalan sinkron atau batch.

Metode API yang tersedia

Chirp memproses ucapan dalam potongan yang jauh lebih besar daripada model lain. Artinya, fitur ini mungkin tidak cocok untuk penggunaan real-time yang sesungguhnya. Chirp tersedia melalui metode API berikut:

Chirp tidak tersedia pada metode API berikut:

  • v2 Speech.StreamingRecognize
  • v1 Speech.StreamingRecognize
  • v1 Speech.Recognize
  • v1 Speech.LongRunningRecognize
  • v1p1beta1 Speech.StreamingRecognize
  • v1p1beta1 Speech.Recognize
  • v1p1beta1 Speech.LongRunningRecognize

Region

Chirp tersedia di region berikut:

  • us-central1
  • europe-west4
  • asia-southeast1

Lihat halaman harga untuk mengetahui detail selengkapnya.

Languages

Anda dapat melihat bahasa yang didukung di daftar bahasa lengkap.

Dukungan dan batasan fitur

Chirp tidak mendukung beberapa fitur STT API:

  • Skor keyakinan: API menampilkan nilai, tetapi bukan sepenuhnya skor keyakinan.
  • Adaptasi ucapan: Tidak ada fitur adaptasi yang didukung.
  • Diarisasi: Diarisasi otomatis tidak didukung.
  • Normalisasi paksa: Tidak didukung.
  • Keyakinan tingkat kata: Tidak didukung.
  • Deteksi bahasa: Tidak didukung.

Chirp mendukung fitur berikut:

  • Tanda baca otomatis: Tanda baca diprediksi oleh model. Fitur ini dapat dinonaktifkan.
  • Word timings: Opsional, ditampilkan.
  • Transkripsi audio yang tidak bergantung pada bahasa: Model secara otomatis menyimpulkan bahasa lisan dalam file audio Anda dan menambahkannya ke hasil.

Sebelum memulai

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Speech-to-Text APIs.

    Enable the APIs

  5. Make sure that you have the following role or roles on the project: Cloud Speech Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Buka IAM
    2. Pilih project.
    3. Klik Berikan akses.
    4. Di kolom New principals, masukkan ID pengguna Anda. Ini biasanya adalah alamat email untuk Akun Google.

    5. Di daftar Pilih peran, pilih peran.
    6. Untuk memberikan peran tambahan, klik Tambahkan peran lain, lalu tambahkan setiap peran tambahan.
    7. Klik Simpan.
    8. Install the Google Cloud CLI.
    9. To initialize the gcloud CLI, run the following command:

      gcloud init
    10. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

      Go to project selector

    11. Make sure that billing is enabled for your Google Cloud project.

    12. Enable the Speech-to-Text APIs.

      Enable the APIs

    13. Make sure that you have the following role or roles on the project: Cloud Speech Administrator

      Check for the roles

      1. In the Google Cloud console, go to the IAM page.

        Go to IAM
      2. Select the project.
      3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

      4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

      Grant the roles

      1. In the Google Cloud console, go to the IAM page.

        Buka IAM
      2. Pilih project.
      3. Klik Berikan akses.
      4. Di kolom New principals, masukkan ID pengguna Anda. Ini biasanya adalah alamat email untuk Akun Google.

      5. Di daftar Pilih peran, pilih peran.
      6. Untuk memberikan peran tambahan, klik Tambahkan peran lain, lalu tambahkan setiap peran tambahan.
      7. Klik Simpan.
      8. Install the Google Cloud CLI.
      9. To initialize the gcloud CLI, run the following command:

        gcloud init
      10. Library klien dapat menggunakan Kredensial Default Aplikasi untuk dengan mudah melakukan autentikasi dengan Google API dan mengirim permintaan ke API tersebut. Dengan Kredensial Default Aplikasi, Anda dapat menguji aplikasi secara lokal dan men-deploy aplikasi tanpa mengubah kode yang mendasarinya. Untuk informasi selengkapnya, lihat Lakukan autentikasi untuk menggunakan library klien.

      11. If you're using a local shell, then create local authentication credentials for your user account:

        gcloud auth application-default login

        You don't need to do this if you're using Cloud Shell.

      Selain itu, pastikan Anda telah menginstal library klien.

      Lakukan pengenalan ucapan sinkron dengan Chirp

      Berikut adalah contoh penerapan pengenalan ucapan sinkron pada file audio lokal menggunakan Chirp:

      Python

      import os
      
      from google.api_core.client_options import ClientOptions
      from google.cloud.speech_v2 import SpeechClient
      from google.cloud.speech_v2.types import cloud_speech
      
      PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
      
      
      def transcribe_chirp(
          audio_file: str,
      ) -> cloud_speech.RecognizeResponse:
          """Transcribes an audio file using the Chirp model of Google Cloud Speech-to-Text API.
          Args:
              audio_file (str): Path to the local audio file to be transcribed.
                  Example: "resources/audio.wav"
          Returns:
              cloud_speech.RecognizeResponse: The response from the Speech-to-Text API containing
              the transcription results.
      
          """
          # Instantiates a client
          client = SpeechClient(
              client_options=ClientOptions(
                  api_endpoint="us-central1-speech.googleapis.com",
              )
          )
      
          # Reads a file as bytes
          with open(audio_file, "rb") as f:
              audio_content = f.read()
      
          config = cloud_speech.RecognitionConfig(
              auto_decoding_config=cloud_speech.AutoDetectDecodingConfig(),
              language_codes=["en-US"],
              model="chirp",
          )
      
          request = cloud_speech.RecognizeRequest(
              recognizer=f"projects/{PROJECT_ID}/locations/us-central1/recognizers/_",
              config=config,
              content=audio_content,
          )
      
          # Transcribes the audio into text
          response = client.recognize(request=request)
      
          for result in response.results:
              print(f"Transcript: {result.alternatives[0].transcript}")
      
          return response
      
      

      Membuat permintaan dengan transkripsi tanpa bahasa diaktifkan

      Contoh kode berikut menunjukkan cara membuat permintaan dengan transkripsi yang tidak bergantung pada bahasa diaktifkan.

      Python

      import os
      
      from google.api_core.client_options import ClientOptions
      from google.cloud.speech_v2 import SpeechClient
      from google.cloud.speech_v2.types import cloud_speech
      
      PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
      
      
      def transcribe_chirp_auto_detect_language(
          audio_file: str,
          region: str = "us-central1",
      ) -> cloud_speech.RecognizeResponse:
          """Transcribe an audio file and auto-detect spoken language using Chirp.
          Please see https://cloud.google.com/speech-to-text/v2/docs/encoding for more
          information on which audio encodings are supported.
          Args:
              audio_file (str): Path to the local audio file to be transcribed.
              region (str): The region for the API endpoint.
          Returns:
              cloud_speech.RecognizeResponse: The response containing the transcription results.
          """
          # Instantiates a client
          client = SpeechClient(
              client_options=ClientOptions(
                  api_endpoint=f"{region}-speech.googleapis.com",
              )
          )
      
          # Reads a file as bytes
          with open(audio_file, "rb") as f:
              audio_content = f.read()
      
          config = cloud_speech.RecognitionConfig(
              auto_decoding_config=cloud_speech.AutoDetectDecodingConfig(),
              language_codes=["auto"],  # Set language code to auto to detect language.
              model="chirp",
          )
      
          request = cloud_speech.RecognizeRequest(
              recognizer=f"projects/{PROJECT_ID}/locations/{region}/recognizers/_",
              config=config,
              content=audio_content,
          )
      
          # Transcribes the audio into text
          response = client.recognize(request=request)
      
          for result in response.results:
              print(f"Transcript: {result.alternatives[0].transcript}")
              print(f"Detected Language: {result.language_code}")
      
          return response
      
      

      Mulai menggunakan Chirp di konsol Google Cloud

      1. Pastikan Anda telah mendaftar ke akun Google Cloud dan membuat project.
      2. Buka Ucapan di Konsol Google Cloud.
      3. Aktifkan API jika belum diaktifkan.
      4. Buka subhalaman Transcriptions.
      5. Klik Transkripsi Baru
      6. Pastikan Anda memiliki ruang kerja STT. Jika belum memilikinya, buat akun.

        1. Buka dropdown Workspace, lalu klik New Workspace.

        2. Dari sidebar navigasi Buat workspace baru, klik Jelajahi.

        3. Klik untuk membuat bucket.

        4. Masukkan nama untuk bucket Anda, lalu klik Continue.

        5. Klik Buat.

        6. Setelah bucket dibuat, klik Select untuk memilih bucket Anda.

        7. Klik Create untuk menyelesaikan pembuatan ruang kerja Anda untuk Speech-to-Text.

      7. Lakukan transkripsi pada audio Anda.

        Halaman pembuatan transkripsi Speech-to-text, yang menampilkan pemilihan atau upload file.
        1. Dari halaman Transkripsi Baru, pilih opsi untuk memilih file audio Anda:
          • Upload dengan mengklik Upload lokal.
          • Klik Cloud Storage untuk menentukan file Cloud Storage yang ada.
        1. Klik Lanjutkan.
        Halaman pembuatan transkripsi Speech-to-text yang menampilkan pemilihan model Chirp dan mengirimkan tugas transkripsi.
        1. Dari bagian Opsi transkrip, pilih Bahasa lisan yang akan Anda gunakan untuk pengenalan dengan Chirp dari pengenal yang dibuat sebelumnya.

        2. Pada drop-down Model*, pilih Chirp.

        3. Di drop-down Region, pilih region, seperti us-central1.

        4. Klik Lanjutkan.

        5. Untuk menjalankan permintaan pengenalan pertama Anda menggunakan Chirp, di bagian utama, klik Kirim.

      8. Lihat hasil transkripsi Chirp Anda.

        1. Dari halaman Transkripsi, klik nama transkripsi.

        2. Di halaman Detail transkripsi, lihat hasil transkripsi, dan jika perlu, putar audio di browser.

      Pembersihan

      Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan di halaman ini, ikuti langkah-langkah berikut.

      1. Optional: Revoke the authentication credentials that you created, and delete the local credential file.

        gcloud auth application-default revoke
      2. Optional: Revoke credentials from the gcloud CLI.

        gcloud auth revoke

      Konsol

    14. In the Google Cloud console, go to the Manage resources page.

      Go to Manage resources

    15. In the project list, select the project that you want to delete, and then click Delete.
    16. In the dialog, type the project ID, and then click Shut down to delete the project.
    17. gcloud

      Delete a Google Cloud project:

      gcloud projects delete PROJECT_ID

      Langkah berikutnya