AI-powered speech-to-text (STT) enables our Laravel call center AI to convert customer calls into text, analyze queries, and respond accurately. Today, weโll integrate OpenAI Whisper, AWS Transcribe, or Google Speech-to-Text to process voice input.
๐๏ธ 1. Choosing a Speech-to-Text (STT) API
To transcribe customer calls, we need an AI service for real-time voice-to-text conversion:
๐น OpenAI Whisper โ Highly accurate and supports multiple languages.
๐น AWS Transcribe โ Works well with call centers and supports speaker identification.
๐น Google Speech-to-Text โ Offers real-time transcription with punctuation.
๐ More about AI STT APIs:
๐ ๏ธ 2. Setting Up Laravel for Speech-to-Text
๐ Step 1: Install Dependencies
For OpenAI Whisper:
composer require openai-php/client
For AWS Transcribe:
composer require aws/aws-sdk-php
For Google Speech-to-Text:
composer require google/cloud-speech
๐ค 3. Implementing Speech-to-Text in Laravel
๐ Option 1: OpenAI Whisper STT
namespace App\Services;
use OpenAI;
class SpeechToTextService
{
protected $client;
public function __construct()
{
$this->client = OpenAI::factory()->withApiKey(env('OPENAI_API_KEY'))->make();
}
public function transcribeAudio($audioFilePath)
{
$response = $this->client->audio()->transcriptions()->create([
'model' => 'whisper-1',
'file' => fopen($audioFilePath, 'r'),
'language' => 'en',
]);
return $response['text'] ?? 'Unable to transcribe.';
}
}
Example Usage in Controller
use App\Services\SpeechToTextService;
public function handleVoiceRequest(Request $request)
{
$stt = new SpeechToTextService();
$text = $stt->transcribeAudio($request->file('audio'));
return response()->json(['transcription' => $text]);
}
๐ Option 2: AWS Transcribe STT
use Aws\TranscribeService\TranscribeServiceClient;
class AWSSpeechToText
{
protected $transcribe;
public function __construct()
{
$this->transcribe = new TranscribeServiceClient([
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
],
]);
}
public function transcribe($audioFileUrl)
{
$result = $this->transcribe->startTranscriptionJob([
'TranscriptionJobName' => 'CallCenterTranscription',
'LanguageCode' => 'en-US',
'Media' => ['MediaFileUri' => $audioFileUrl],
'MediaFormat' => 'mp3',
]);
return $result['TranscriptionJob']['TranscriptionJobStatus'];
}
}
๐น Note: AWS processes audio asynchronously, so we need to check the job status periodically.
๐ 4. Using STT for Call Center Conversations
Once we transcribe customer speech, we process it with our AI bot.
๐ Example: Pass Transcribed Text to AI for Response
use App\Services\AIService;
use App\Services\SpeechToTextService;
public function processVoiceQuery(Request $request)
{
$stt = new SpeechToTextService();
$query = $stt->transcribeAudio($request->file('audio'));
$ai = new AIService();
$response = $ai->generateResponse($query);
return response()->json(['reply' => $response]);
}
๐ค 5. Testing the AI Call Center STT System
1๏ธโฃ Record a voice query (e.g., “Whatโs my account balance?”).
2๏ธโฃ Upload the audio file via API request.
3๏ธโฃ STT converts it to text.
4๏ธโฃ AI bot processes the text and generates a response.
5๏ธโฃ The response is converted back to speech (coming in Day 3).
๐ Meta Description
“Integrate AI-powered speech-to-text (STT) in a Laravel call center bot using OpenAI Whisper, AWS Transcribe, or Google Speech-to-Text. Automate call handling with AI! #AIVoiceBot #STTIntegration”