Skip to content

Latest commit

 

History

History

playground

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Spring AI Converse ⪧ Playground

Welcome to the playground sample application.

You will enable features by activating Spring profiles.

How to run

AssemblyAI

Prerequisites

Set these environment variables

export ASSEMBLYAI_API_KEY=

Add an appropriate value for each environment variable above.

Navigate to the playground directory and activate a Spring profile

cd playground
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=assemblyai,dev

Back in the terminal shell, press Ctrl+C to shutdown.

Available endpoints

http POST :8080/api/assemblyai/transcribe \ 
  Content-Type:application/octet-stream \
  @/path/to/your/audio/file

Replace /path/to/your/audio/file above with a valid absolute path to your audio file

Elevenlabs

Prerequisites

Set these environment variables

export ELEVENLABS_API_KEY=

Add an appropriate value for each environment variable above.

Navigate to the playground directory and activate a Spring profile

cd playground
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=elevenlabs,dev

Back in the terminal shell, press Ctrl+C to shutdown.

Available endpoints

http POST :8080/api/elevenlabs/speak \                                                                                                                                                                                                                     ✔  10s    12:05:55   
  Content-Type:application/json \
  text="A modern-day warrior.  Mean, mean stride.  Today's Tom Sawyer.  Mean, mean pride."

or if you want to download a copy of the audio

http --download POST :8080/api/elevenlabs/speak \
  Content-Type:application/json \
  text="Say you can't sleep, baby, I know.  That's that me espresso." \
  outputFormat==PCM_16000 \
  toFile==true

Google ⪧ Speech-to-text

Prerequisites

  • a Google Cloud account
    • to create a new account, visit this link and click Create Account
  • gcloud CLI (502.0.0 or better)

Authenticate

gcloud config set project <GOOGLE_PROJECT_ID> \
  && gcloud auth application-default login

Replace <GOOGLE_PROJECT_ID> above with a valid identifier of a Google project

Enable the API (if not already enabled)

Visit https://console.developers.google.com/apis/api/speech.googleapis.com/overview and click the Enable button.

Set these environment variables

# Required
export GOOGLE_PROJECT_ID=
# Optional
export GOOGLE_STT_LANGUAGE_CODE=
export GOOGLE_STT_MODEL

Add an appropriate value for each environment variable above.

Navigate to the playground directory and activate a Spring profile

cd playground
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=google,dev

Back in the terminal shell, press Ctrl+C to shutdown.

Available endpoints

http POST :8080/api/google/transcribe \ 
  Content-Type:application/octet-stream \
  @/path/to/your/audio/file

Replace /path/to/your/audio/file above with a valid absolute path to your audio file

Google ⪧ Text-to-speech

Prerequisites

  • a Google Cloud account
    • to create a new account, visit this link and click Create Account
  • gcloud CLI (502.0.0 or better)

Authenticate

gcloud config set project <GOOGLE_PROJECT_ID> \
  && gcloud auth application-default login

Replace <GOOGLE_PROJECT_ID> above with a valid identifier of a Google project

Enable the API (if not already enabled)

Visit https://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview and click the Enable button.

Set these environment variables

# Optional
export GOOGLE_TTS_LANGUAGE_CODE=
export GOOGLE_TTS_VOICE_GENDER=
export GOOGLE_TTS_AUDIO_ENCODING=

Add an appropriate value for each environment variable above.

Navigate to the playground directory and activate a Spring profile

cd playground
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=google,dev

Back in the terminal shell, press Ctrl+C to shutdown.

Available endpoints

http POST :8080/api/google/speak \
  Content-Type:application/json \
  text="Say you can't sleep, baby, I know.  That's that me espresso."

Picovoice ⪧ Cheetah ⪧ Speech-to-text

Prerequisites

Set these environment variables

# Required
export PICOVOICE_ACCESS_KEY=
# Optional
export PICOVOICE_MODEL_PATH=
export PICOVOICE_ENABLE_AUTO_PUNCTUATION=

Add an appropriate value for each environment variable above.

Navigate to the playground directory

cd playground

Execute the following script to seed the model files

files=(
   "cheetah_params.pv"
   "cheetah_params_de.pv" 
   "cheetah_params_es.pv"
   "cheetah_params_fr.pv"
   "cheetah_params_it.pv"
   "cheetah_params_pt.pv"
)

for file in "${files[@]}"; do
   curl -O "https://raw.githubusercontent.com/Picovoice/cheetah/master/lib/common/$file"
done

mv *.pv target/classes

If you want to override the default model, remember to set an absolute path for the PICOVOICE_MODEL_PATH environment variable e.g., export PICOVOICE_MODEL_PATH=${user.dir}/target/classes/cheetah_params_de.pv

Repackage and run activating a Spring profile

mvn package
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=picovoice,dev

Back in the terminal shell, press Ctrl+C to shutdown.

Available endpoints

http POST :8080/api/picovoice/cheetah/transcribe \ 
  Content-Type:application/octet-stream \
  @/path/to/your/audio/file

Replace /path/to/your/audio/file above with a valid absolute path to your audio file

Note: you are limited to providing .au, .aiff, or .wav audio files at 16kHz with a 16bit sample rate.

Picovoice ⪧ Leopard ⪧ Speech-to-text

Prerequisites

Set these environment variables

# Required
export PICOVOICE_ACCESS_KEY=
# Optional
export PICOVOICE_MODEL_PATH=
export PICOVOICE_ENABLE_AUTO_PUNCTUATION=
export PICOVOICE_ENABLE_DIARIZATION=
export PICOVOICE_VERBOSE=

Add an appropriate value for each environment variable above.

Navigate to the playground directory

cd playground

Execute the following script to seed the model files

files=(
   "leopard_params.pv"
   "leopard_params_de.pv" 
   "leopard_params_es.pv"
   "leopard_params_fr.pv"
   "leopard_params_it.pv"
   "leopard_params_ja.pv"
   "leopard_params_ko.pv"
   "leopard_params_pt.pv"
)

for file in "${files[@]}"; do
   curl -O "https://raw.githubusercontent.com/Picovoice/leopard/master/lib/common/$file"
done

mv *.pv target/classes

If you want to override the default model, remember to set an absolute path for the PICOVOICE_MODEL_PATH environment variable e.g., export PICOVOICE_MODEL_PATH=${user.dir}/target/classes/leopard_params_ja.pv

Repackage and run activating a Spring profile

mvn package
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=picovoice,dev

Back in the terminal shell, press Ctrl+C to shutdown.

Available endpoints

http POST :8080/api/picovoice/leopard/transcribe \ 
  Content-Type:application/octet-stream \
  @/path/to/your/audio/file

Replace /path/to/your/audio/file above with a valid absolute path to your audio file

Note: you are limited to providing .3gp, .flac, .mp3, .mp4, .m4a, .ogg, .opus, .vorbis, .wav, or .webm audio files with a 16bit sample rate.