Skip to main content

The package is intended for STT, LLM and TSS models chaining.

Project description

cockatoo_chain

This repo is intended for STT, LLM and TSS models chaining.

Installation

Use below command to install the cockatoo_chain package:

# Create Python virtual environment
$ python -m venv env

# Enter virtual Python runtime
$ source env/bin/activate

# Install the target package
$ pip install cockatoo_chain

# Validate the installation
$ python -c 'import cockatoo_chain' && echo 'Success'
Success

Development Mode

Development Mode is intended for users who wish to contribute to the repo and thus needs to install additional dev-related packages for, e.g., code quality checking, to satisfy the standard of the repo. If you hope to contribute to the repository, please follow up the follow instructions:

Create virtual environment by poetry

# Force poetry to build virtual environment in the repo.
$ poetry config virtualenvs.in-project true

# Create virtual environment
$ poetry env use python

# Confirm the created virtual environment
$ poetry env info

Enter virtual environment and installed packages

# Get the command to enter virtual environment
$ poetry env activate
$ source activate <your venv>
$ make init-repo-setup

Model A Usage

From cockagoo_chain package, you can easily access the power of Model A (Speech-to-text) with a few lines of codes. We will learn how to from this section. For the time being, cockagoo_chain support below types of model A:

Name Type Supported language Supported file type Note
open_ai_whisper Remote API en, cn and more File uploads are currently limited to 25 MB, and the following input file types are supported: mp3, mp4, mpeg, mpga, m4a, wav, and webm Official doc
gcp_stt Remote API en, cn and more For details, please refer to this link Official doc

Get supported Model A options

You can use below code snippet to get the supported model A options:

>>> from cockatoo_chain.utils import model_a
>>> model_type = model_a.ModelType
>>> list(model_type)
[<ModelType.OPEN_AI_WHISPER: 'open_ai_whisper'>]

Transform input audio file into text

Below code snippet demonstrates how to obtain the OpenAI whipser wrapper for model A and apply it to transform the audio file into text:

>>> test_en_audio_file_path = '~/test_audio_files/en_20240108_johnlee.wav'
>>> model_a_wrapper = model_a.get(model_type.OPEN_AI_WHISPER)
>>> response = model_a_wrapper.audio_2_text(test_en_audio_file_path)
>>> response
Audio2TextData(
    text='Hello, this is for testing in English. We will use this to evaluate model SST...',
    spent_time_sec=7.87896990776062,
    audio_file_path='/root/test_audio_files/en_20240108_johnlee.wav')
>>> response.text
'Hello, this is for testing in English. We will use this to evaluate model SST and see how it performs. Thanks.'

Model C Usage

From cockagoo_chain package, you can easily access the power of Model C (Text-to-speech) with a few lines of codes. We will learn how to from this section. For the time being, cockagoo_chain support below types of model C:

Name Type Supported language Supported output file type Note
gcp_text_2_speech Remove API en, cn and more wav Offical doc

Get supported Model C options

>>> from cockatoo_chain.utils import model_c
>>> mt = model_c.ModelType
>>> list(mt)
[<ModelType.GCP_TEXT_2_SPEECH: 'gcp_text_2_speech'>]

Transform text into speech

Below code snippet demonstrates how to obtain the GCP text-to-speech wrapper as model C and apply it to transform give text into speech and save it as audio file:

>>> mc_imp = model_c.get(mt.GCP_TEXT_2_SPEECH)
>>> mc_imp.name
'GCP/text-to-speech'
>>> mc_imp.text_2_audio("Nice to meet you all and welcome to join Cockatoo-AI's group meeting!")
Text2AudioData(
    text="Nice to meet you all and welcome to join Cockatoo-AI's group meeting!",
    spent_time_sec=1.822951,
    generated_audio_file_path='/tmp/gcp_tts_output.wav')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cockatoo_chain-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cockatoo_chain-0.1.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file cockatoo_chain-0.1.2.tar.gz.

File metadata

  • Download URL: cockatoo_chain-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.11.0-24-generic

File hashes

Hashes for cockatoo_chain-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9e696e1a488ddbd558e7be6d469361bb3d916c4675a266173cdda3b0a95cdf1b
MD5 5afabfabb09e1263cae0301adba487bb
BLAKE2b-256 214c3c1fdf948cf087f903a9ee953bfa46a049be4b7ae62c6c96f094b68256b5

See more details on using hashes here.

File details

Details for the file cockatoo_chain-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cockatoo_chain-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.11.0-24-generic

File hashes

Hashes for cockatoo_chain-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 62619fabe8e6c45fa79b992bc802706bf9ef4002d4da10a47fc41c7925817db3
MD5 76e3e5360a56ba6d47b9bc967dc93a2f
BLAKE2b-256 d21c27816f37ca6df2f833ba4f2a6140caeb67585e0bc2cf36e6e4c76e6890ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page