Posted
I am currently working on a personal themed script, something like universal hub but personalized to me like a custom HUD. I wish to add a form of TTS to this script to narrate certain things.
I have searched all exploit formus that I could find, only getting results about playing audio uploaded to roblox to the server. So I want to ask if there is a way to play audio files not uploaded to roblox through an executor?
Replied
-- Initializing the YourBot TTS Core for ADM_Storm
-- This script utilizes getcustomasset to play non-Roblox uploaded audio files
local HttpService = game:GetService("HttpService")
local SoundService = game:GetService("SoundService")
-- Creating a global function that ADM_Storm can call from any part of the HUD
-- This function handles the conversion of text into a local audio file
_G.SpeakLocal = function(text, languageCode)
-- Defaulting to English (US) if no language code is provided
local lang = languageCode or "en-US"
-- Encoding the string to ensure it is compatible with the HTTP request
local encodedText = HttpService:UrlEncode(text)
-- Utilizing the Google Translate TTS API for high-quality voice generation
-- This allows us to get audio data without uploading to the Roblox library
local ttsUrl = "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=" .. lang .. "&q=" .. encodedText
-- Executing the request to download the audio binary
-- Most executors on WeAreDevs support the 'request' function
local success, response = pcall(function()
return request({
Url = ttsUrl,
Method = "GET"
})
end)
if success and response.Success then
-- Defining the path in the executor's 'workspace' folder
local fileName = "ADM_Storm_TTS.mp3"
-- Writing the binary data to a local file on the computer
-- This bypasses the need for any rbxassetid moderation
writefile(fileName, response.Body)
-- Creating a standard Sound instance for playback
local sound = Instance.new("Sound")
sound.Name = "StormHUD_Voice"
-- Converting the local file path into a temporary content ID
-- getcustomasset is the specific function that makes local files playable
sound.SoundId = getcustomasset(fileName)
sound.Volume = 5
sound.Parent = SoundService
-- Triggering the narration
sound:Play()
-- Ensuring the Sound object is removed after it finishes to prevent memory leaks
sound.Ended:Connect(function()
sound:Destroy()
end)
else
-- Warning the console if the TTS service is unreachable
warn("Failed to generate TTS for ADM_Storm. Check internet connection or executor API.")
end
end
-- Fullscript Example of usage within the personalized HUD logic:
-- _G.SpeakLocal("Welcome to your custom hub, Storm. Systems are online.")
-- To play a pre-existing local file (not TTS) that is already in your workspace:
_G.PlayStoredAudio = function(fileName)
if isfile(fileName) then
local sound = Instance.new("Sound")
sound.SoundId = getcustomasset(fileName)
sound.Volume = 2
sound.Parent = SoundService
sound:Play()
sound.Ended:Connect(function()
sound:Destroy()
end)
else
warn("File " .. fileName .. " was not found in the workspace folder.")
end
end
-- Example of playing a local file named 'intro.mp3'
-- _G.PlayStoredAudio("intro.mp3")
Cancel
Post
I Help People, Ask me.
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post