Blog

All Blog Posts  |  Next Post  |  Previous Post

Voice-Controlled Maps in Delphi with TMS AI Studio + OpenAI TTS/STT

Monday, August 11, 2025

TMS Software Delphi  Components

The world of Delphi development just took another leap into the future. With the latest enhancements to TMS AI Studio, we now have full integration of OpenAI’s Text-to-Speech (TTS) and Speech-to-Text (STT) capabilities.
What does this mean? It means your Delphi apps can now listen and talk — and even respond with intelligent, real-time actions.
And the first mind-blowing demo?
Voice-controlled route navigation on an interactive map.

TMS Software Delphi  Components


From Your Voice → MP3 → OpenAI → Intelligent Action

At the core of this demo lies a simple but powerful idea:
You speak your command — e.g., “Show me the route from Brussels to Paris” — and your Delphi app figures out exactly what you mean and acts on it.

The process works like this:

  1. Record from microphone
    Using the open-source TMS AudioRecorder Library, we capture the voice via the microphone and return it as an MP3 stream. This is done entirely from Delphi code with just a few lines:

    // start the audio recording AudioRecorder.ClearRecordedData; AudioRecorder.StartRecording; // stop the audio recording and get the sounds as MP3 stream var s: TMemoryStream; begin if FIsSpeaking then begin ar.StopRecording; s := ar.GetMP3Stream(20500); s.Position := 0; // use the TTMSFNCCloudAI component to have it transscribed via OpenAI to text TMSFNCCloudAI1.Transcribe(s); s.Free; end; end;
  2. Send MP3 to OpenAI for transcription (STT)
    The MP3 is sent to OpenAI’s STT API, which returns the transcribed text.

    // the call to: TMSFNCCloudAI1.Transcribe(s); // triggers the event TMSFNCCloudAI.OnTranscribeAudio when it is ready to return the audio as text: procedure TForm1.DoTranscribe(Sender: TObject; HttpStatusCode: Integer; HttpResult, Text: string); begin if HttpStatusCode div 100 = 2 then begin // we use the transcribed text as prompt for the LLM TMSFNCCloudAI1.Context.Text := Text; TMSFNCCloudAI1.Execute('abc'); end else memo1.Lines.Text := 'Error ' + HttpStatusCode.ToString+ ' ' + HttpResult; end;
  3. Pass text as a command to OpenAI (with Function Calling)
    The transcribed text is sent to OpenAI’s Chat API, where function calling is used to trigger a Delphi function that plots a route on a map.

  4. Show route with OpenRoute + OpenLayers
    The function retrieves directions from OpenRoute and displays them on an interactive OpenLayers map component — all within your Delphi application using the TTMSFNCMaps component from TMS FNC Maps 


 Everything brought together in a VCL demo project, this looks like:

 TMS Software Delphi  Components

You can download the full source code of this demo here. To run this compile & run this example on your machine, make sure to install the latest version of TMS AI Studio and TMS FNC Maps.


Function Calling: The AI Knows What to Do

This isn’t just “send text and get text back.”
We’re using OpenAI Function Calling so that when the AI detects a route command, it automatically calls the ShowRoute function that was setup via:

procedure TForm1.InitTools; var tool: TTMSFNCCloudAITool; param: TTMSFNCCloudAIParameter; begin inherited;

tool := TMSFNCCloudAI1.Tools.Add; tool.Name := 'ShowRoute'; tool.Description := 'Show the route between two places, based on geocoordinate points on the map'; param := tool.Parameters.Add; param.Name := 'startplace'; param.&Type := ptString; param.Required := true; param.Description := 'the name of the first place'; param := tool.Parameters.Add; param.Name := 'startlon'; param.&Type := ptString; param.Required := true; param.Description := 'the longitude of the start coordinate'; param := tool.Parameters.Add; param.Name := 'startlat'; param.&Type := ptString; param.Required := true; param.Description := 'the latitude of the start coordinate'; param := tool.Parameters.Add; param.Name := 'endplace'; param.&Type := ptString; param.Required := true; param.Description := 'the name of the second place'; param := tool.Parameters.Add; param.Name := 'endlon'; param.&Type := ptString; param.Required := true; param.Description := 'the longitude of the end coordinate'; param := tool.Parameters.Add; param.Name := 'endlat'; param.&Type := ptString; param.Required := true; param.Description := 'the latitude of the end coordinate'; tool.OnExecute := ShowRoute; end;

This means you don’t need to manually parse text or guess what the user meant — the AI does the intent recognition and calls your Delphi function directly. Here is gets the parameters that were configured. In addition to use the OpenRoute directions API to calculate the route, it also uses OpenAI TTS to speak the route calculation it will perform:

procedure TForm1.ShowRoute(Sender: TObject; Args: TJSONObject; var Result: string); var cStart, cEnd: TTMSFNCMapsCoordinateRec; nStart, nEnd: string; begin if Args.Count > 0 then begin nStart := Args.GetValue<string>('startplace'); cStart.Longitude := Args.GetValue<double>('startlon'); cStart.Latitude := Args.GetValue<double>('startlat'); nEnd := Args.GetValue<string>('endplace'); cEnd.Longitude := Args.GetValue<double>('endlon'); cEnd.Latitude := Args.GetValue<double>('endlat'); // Use OpenAI TTS and have this text spoken on the machine TMSFNCCloudAI1.Speak('I am calculating the route from ' + nStart +' to ' + nEnd); // Use the free OpenRoute directions service to calculate the route ShowDirections(nStart, nEnd, cStart, cEnd); end; end;


The code to show the directions is done by using the TTMSFNCDirections component to request directions and then via an anonymouse method call, the resulting route is returned and displayed as a polyline and a start and end marker on the map:

procedure TForm1.ShowDirections(FromPlace, ToPlace: string; FromCoord, ToCoord: TTMSFNCMapsCoordinateRec); begin TMSFNCDirections1.GetDirections(FromCoord, ToCoord, procedure(const ARequest: TTMSFNCDirectionsRequest; const ARequestResult: TTMSFNCCloudBaseRequestResult) var it: TTMSFNCDirectionsItem; p: TTMSFNCMapsPolyline; Bounds: TTMSFNCMapsBoundsRec; begin TMSFNCMaps1.ClearPolylines; TMSFNCMaps1.ClearMarkers; if ARequestResult.Success then begin if ARequest.Items.Count > 0 then begin TMSFNCMaps1.BeginUpdate; it := ARequest.Items[0]; TMSFNCMaps1.AddMarker(it.Legs[0].StartLocation.ToRec, FromPlace, DEFAULTWAYPOINTMARKER); TMSFNCMaps1.AddMarker(it.Legs[0].EndLocation.ToRec, ToPlace, DEFAULTENDMARKER); p := TTMSFNCMapsPolyline(TMSFNCMaps1.AddPolyline(it.Coordinates.ToArray)); p.StrokeColor := gcBlue; p.StrokeOpacity := 0.5; p.StrokeWidth := 5; // grow the boundary 15% Bounds := InflateBounds(it.Coordinates.Bounds.ToRec, 15); TMSFNCMaps1.ZoomToBounds(Bounds); TMSFNCMaps1.EndUpdate; end; end; end); end;

Why This Is a Game-Changer for Delphi Developers

With this TTS/STT integration, Delphi apps can now be fully voice-controlled.
And because we’re working in TMS AI Studio, the possibilities are endless:

  • Hands-free map navigation

  • Voice-activated data queries

  • Real-time spoken feedback to the user

  • Natural conversation between user and app

And all of this runs natively in Delphi VCL or FMX applications. See everything in action in this video:



A Glimpse of the Future

This “voice to route” demo is just the start. Imagine:

  • A Delphi CRM app where you say “Show all customers from Belgium who ordered last month” — and the grid updates instantly.

  • A Delphi medical app where doctors dictate notes and instantly trigger patient record updates.

  • A Delphi IoT control panel where you say “Turn on greenhouse lights until 8pm” and it just happens.

With TMS AI Studio + OpenAI + Delphi, we’re now in an era where your apps can understand and speak the user’s language — literally.


💡 Stay tuned — even more mind-blowing AI integrations are coming to TMS AI Studio soon.
We’ve only scratched the surface of what’s possible when Delphi meets world-class AI.



Bruno Fierens




This blog post has not received any comments yet.



Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post