Welcome to my Ko Paing website.Today I'll going to show you how to creat Transcript AI Tool in sketchware pro step by step.Please follow step by step.
What is Sketchware Pro?
Sketchware Pro is a highly popular, community-driven Mobile IDE (Integrated Development Environment) that allows users to create fully functional, native Android applications directly on an Android device, without the need for a computer.
It is an advanced, extended version of the original Sketchware application, enhanced by a dedicated developer community to unlock powerful features that were previously restricted.
If you don't have Sketchware Pro yet, you can download it by going to the Sketchware Pro website.
Now I'm using sketchware v6.4.0 rc-05 of sketchware version.ok let start
To use Gemini Api key to transcribe, you need to have an account in Google AI Studio and have an Api key.
To get started, click the Plus button to create a New Project in Sketchware Pro.
Enter the logo and name of your favorite application and click CREAT APP.
Create the UI design of the application as you like. The main things you need are edittext1 to enter the Google AI Studio Api Key, button1 to select the Video to be transcribed, textview1 to show the File Path, spinner1 for Language, and textview2 for the Transcript Result returned by AI.
After everything is ready, to set the Transcript Language, you need to write the following code in the OnCreate event in the ASD Block as shown in the image. The circled lang_list.add("Burmese(Myanmar)");
lang_list.add("English");
lang_list.add("Thai (ไทย)"); are the three specified languages. You can add more languages here.
OnCreat Code:
ArrayList<String> lang_list = new ArrayList<>();
lang_list.add("Burmese (Myanmar)");
lang_list.add("English");
lang_list.add("Thai (ไทย)");
// you want to creat lang_list list string veriable
android.widget.ArrayAdapter<String> adapter = new android.widget.ArrayAdapter<>(this, android.R.layout.simple_spinner_item, lang_list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter);
note: Here you need to create a variable named List String lang_list.
Next, create two components: File Picker Component fp type (*/*) and Request Network net name.
In OnFile Pick, add the following block and display the File Path Location in textview1.
In OnFile Pick, add the following block and display the File Path Location in textview1.
Button2 OnClick Code:
final String apiKey = edittext1.getText().toString().trim();
final String path = mediaPath;
if (apiKey.isEmpty()) {
SketchwareUtil.CustomToast(getApplicationContext(), "Please enter Gemini API Key", 0xFFFFFFFF, 12, 0xFF000000, 60, SketchwareUtil.CENTER);
return;
}
if (path == null || path.isEmpty()) {
SketchwareUtil.CustomToast(getApplicationContext(), "Please select a file first", 0xFFFFFFFF, 12, 0xFF000000, 60, SketchwareUtil.CENTER);
return;
}
textview2.setText("Initializing Large File Upload... Please wait...");
new Thread(new Runnable() {
@Override
public void run() {
try {
java.io.File file = new java.io.File(path);
long fileSize = file.length();
String mimeType = "application/octet-stream";
String lowerPath = path.toLowerCase();
if (lowerPath.endsWith(".mp3")) mimeType = "audio/mp3";
else if (lowerPath.endsWith(".wav")) mimeType = "audio/wav";
else if (lowerPath.endsWith(".m4a")) mimeType = "audio/m4a";
else if (lowerPath.endsWith(".mp4")) mimeType = "video/mp4";
else if (lowerPath.endsWith(".3gp")) mimeType = "video/3gp";
else if (lowerPath.endsWith(".mkv")) mimeType = "video/x-matroska";
int selectedPosition = spinner1.getSelectedItemPosition();
String targetLanguage = "Burmese script";
if (selectedPosition == 1) targetLanguage = "English";
else if (selectedPosition == 2) targetLanguage = "Thai language";
final String finalTargetLanguage = targetLanguage;
String initUrl = "https://generativelanguage.googleapis.com/upload/v1beta/files?key=" + apiKey;
java.net.URL url = new java.net.URL(initUrl);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("X-Goog-Upload-Protocol", "resumable");
conn.setRequestProperty("X-Goog-Upload-Command", "start");
conn.setRequestProperty("X-Goog-Upload-Header-Content-Length", String.valueOf(fileSize));
conn.setRequestProperty("X-Goog-Upload-Header-Content-Type", mimeType);
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
org.json.JSONObject metaFile = new org.json.JSONObject();
metaFile.put("displayName", file.getName());
org.json.JSONObject metaBody = new org.json.JSONObject();
metaBody.put("file", metaFile);
java.io.OutputStream os = conn.getOutputStream();
os.write(metaBody.toString().getBytes("utf-8"));
os.close();
int initCode = conn.getResponseCode();
if (initCode != 200) {
showError("Upload Init Failed. Code: " + initCode);
return;
}
String uploadUrl = conn.getHeaderField("X-Goog-Upload-URL");
conn.disconnect();
updateStatus("Uploading File (" + (fileSize / 1024 / 1024) + " MB)...");
java.net.HttpURLConnection uploadConn = (java.net.HttpURLConnection) new java.net.URL(uploadUrl).openConnection();
uploadConn.setRequestMethod("POST");
uploadConn.setRequestProperty("X-Goog-Upload-Offset", "0");
uploadConn.setRequestProperty("X-Goog-Upload-Command", "upload, finalize");
uploadConn.setRequestProperty("Content-Length", String.valueOf(fileSize));
uploadConn.setDoOutput(true);
java.io.FileInputStream fis = new java.io.FileInputStream(file);
java.io.OutputStream uploadOs = uploadConn.getOutputStream();
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
uploadOs.write(buffer, 0, bytesRead);
}
uploadOs.close();
fis.close();
int uploadCode = uploadConn.getResponseCode();
if (uploadCode != 200 && uploadCode != 201) {
showError("Upload Chunk Failed. Code: " + uploadCode);
return;
}
java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(uploadConn.getInputStream(), "utf-8"));
StringBuilder uploadRes = new StringBuilder();
String line;
while ((line = br.readLine()) != null) uploadRes.append(line.trim());
br.close();
uploadConn.disconnect();
org.json.JSONObject fileJson = new org.json.JSONObject(uploadRes.toString());
String fileUri = fileJson.getJSONObject("file").getString("uri");
String fileName = fileJson.getJSONObject("file").getString("name"); // files/xxxx
boolean isUploaded = false;
String checkUrl = "https://generativelanguage.googleapis.com/v1beta/" + fileName + "?key=" + apiKey;
int maxAttempts = 20;
while (maxAttempts > 0) {
updateStatus("Server processing file... Please wait...");
java.net.HttpURLConnection checkConn = (java.net.HttpURLConnection) new java.net.URL(checkUrl).openConnection();
checkConn.setRequestMethod("GET");
java.io.BufferedReader cBr = new java.io.BufferedReader(new java.io.InputStreamReader(checkConn.getInputStream(), "utf-8"));
StringBuilder cRes = new StringBuilder();
while ((line = cBr.readLine()) != null) cRes.append(line.trim());
cBr.close();
checkConn.disconnect();
org.json.JSONObject checkJson = new org.json.JSONObject(cRes.toString());
String state = checkJson.getString("state");
if ("ACTIVE".equals(state)) {
isUploaded = true;
break;
} else if ("FAILED".equals(state)) {
showError("File processing failed on server.");
return;
}
Thread.sleep(3000);
maxAttempts--;
}
if (!isUploaded) {
showError("File processing timeout.");
return;
}
updateStatus("Transcribing with Gemini 2.5 Flash...");
String aiUrl = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=" + apiKey;
java.net.HttpURLConnection aiConn = (java.net.HttpURLConnection) new java.net.URL(aiUrl).openConnection();
aiConn.setRequestMethod("POST");
aiConn.setRequestProperty("Content-Type", "application/json");
aiConn.setDoOutput(true);
// Gemini Payload
org.json.JSONObject jsonBody = new org.json.JSONObject();
org.json.JSONArray contents = new org.json.JSONArray();
org.json.JSONObject contentObj = new org.json.JSONObject();
org.json.JSONArray parts = new org.json.JSONArray();
org.json.JSONObject textPart = new org.json.JSONObject();
textPart.put("text", "You are an expert transcriber. Transcribe the file accurately. Then, translate that transcription into " + finalTargetLanguage + ". Output ONLY the final text.");
parts.put(textPart);
org.json.JSONObject fileDataPart = new org.json.JSONObject();
org.json.JSONObject fileData = new org.json.JSONObject();
fileData.put("mimeType", mimeType);
fileData.put("fileUri", fileUri);
fileDataPart.put("fileData", fileData);
parts.put(fileDataPart);
contentObj.put("parts", parts);
contents.put(contentObj);
jsonBody.put("contents", contents);
java.io.OutputStream aiOs = aiConn.getOutputStream();
aiOs.write(jsonBody.toString().getBytes("utf-8"));
aiOs.close();
java.io.BufferedReader aiBr = new java.io.BufferedReader(new java.io.InputStreamReader(aiConn.getInputStream(), "utf-8"));
StringBuilder aiRes = new StringBuilder();
while ((line = aiBr.readLine()) != null) aiRes.append(line.trim());
aiBr.close();
aiConn.disconnect();
org.json.JSONObject resObj = new org.json.JSONObject(aiRes.toString());
final String textResult = resObj.getJSONArray("candidates")
.getJSONObject(0)
.getJSONObject("content")
.getJSONArray("parts")
.getJSONObject(0)
.getString("text");
runOnUiThread(new Runnable() {
@Override
public void run() {
textview2.setText(textResult);
}
});
} catch (final Exception e) {
showError("Error: " + e.getMessage());
}
}
// Helper functions for UI update
private void updateStatus(final String msg) {
runOnUiThread(new Runnable() { @Override public void run() { textview2.setText(msg); } });
}
private void showError(final String msg) {
runOnUiThread(new Runnable() { @Override public void run() { textview2.setText(msg); } });
}
}).start();
Once all the above steps are completed, insert the above code in the ASD Block on the On Click of the Transcribe button. This code converts large file size videos or audio to Base64 and uses the Google File Api, making it convenient for you to use.Once all these steps are complete, you can start using your project by clicking the Run button in Sketchware Pro.







