Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Write a deepgramTranscribeVideo() Function using Java #4482

Closed
4 tasks
christyjacob4 opened this issue Oct 14, 2022 · 13 comments
Closed
4 tasks

⚡ Write a deepgramTranscribeVideo() Function using Java #4482

christyjacob4 opened this issue Oct 14, 2022 · 13 comments
Assignees
Labels
good first issue Good for newcomers product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@christyjacob4
Copy link
Member

💭 Introduction

Appwrite Functions allow you to extend and customize your Appwrite server functionality by executing your custom code 🤩 You can learn more in our official Appwrite Functions docs.

The backbone of Appwrite Functions is Open Runtimes, an environment for serverless cloud computing. Since all Open Runtime functions are valid Appwrite functions, we are looking for contributors to extend the Open Runtimes Examples repository.

Your task is to implement deepgramTranscribeVideo() function using Java. Please make sure to look at existing function examples and use them as a template for your function. This will help you keep the proper structure as well as provide information on how to test the function.

⚡ Function Details

Transcribe a video into written text. If necessary, introduce Deepgram API secret keys as function variables. The payload must accept a WAV file URL, and the response from Deepgram should be returned.

Example function payload:

{"fileUrl":"https://rawcdn.githack.com/deepgram-devs/transcribe-videos/62fc7769d6e2bf38e420ee5224060922af4546f7/deepgram.mp4"}

Successful function response:

{"success":true,"deepgramData":{}}

Error function response:

{"success":false,"message":"Please provide a valid file URL."}

🎯 Requirements

  • Experience with Appwrite.
  • Experience with Java.
  • Knowledge to implement deepgramTranscribeVideo function.
  • Experience with Docker.

✅ Task Summary

  • Ask to be assigned to the issue.
  • Implement function deepgramTranscribeVideo() in Java/ folder.
  • Manually execute the newly implemented function to ensure it works.
  • Submit a pull request in open-runtimes/examples and include screenshots of successful execution.

If you have questions, need any help, or just want to hang out, make sure to join us on our Discord server.

Happy Appwriting!

@christyjacob4 christyjacob4 added feature product / functions Fixes and upgrades for the Appwrite Functions. good first issue Good for newcomers hacktoberfest Issues that can win you some cool swags! labels Oct 14, 2022
@tanishk-23
Copy link

@christyjacob4 can you assign this issue to me?

@codingmickey
Copy link

hi @christyjacob4, can I work on this issue?

@tessamero
Copy link

@tanishk-23 , thanks for your interest! You may work on this issue 🙏 Happy hacking! 🎃

@codingmickey , we are assigning people on a first come first serve basis. If @tanishk-23 isn't able to complete this issue, we will reassign it accordingly. In the meantime, you can find other hacktoberfest issues via our website.

@stnguyen90 stnguyen90 removed the hacktoberfest Issues that can win you some cool swags! label Nov 7, 2022
@Faizan711
Copy link

Is this issue still unassigned, if so i would like to be assigned for it.

@stnguyen90
Copy link
Contributor

@Faizan711, assigned! Thank you for your interest!

@ANUSHRAV01
Copy link

@stnguyen90 I feel this issue still exist
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class AppwriteFunction {
public static JsonObject deepgramTranscribeVideo(JsonObject data) throws Exception {
String fileUrl = data.get("fileUrl").getAsString();

if (fileUrl == null || fileUrl.isEmpty()) {
  return errorResponse("Please provide a valid file URL.");
}

String deepgramApiKey = System.getenv("DEEPGRAM_API_KEY"); // Set your Deepgram API key as an environment variable
if (deepgramApiKey == null || deepgramApiKey.isEmpty()) {
  return errorResponse("Please set your Deepgram API key as an environment variable.");
}

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
    .url("https://proxy.deepgram.com/v1/listen")
    .post(RequestBody.create("{\n  \"url\": \"" + fileUrl + "\",\n  \"metadata\": {\n    \"client_name\": \"appwrite\",\n    \"client_version\": \"v1\",\n    \"api_key\": \"" + deepgramApiKey + "\"\n  }\n}", okhttp3.MediaType.parse("application/json")))
    .build();

Response response = client.newCall(request).execute();
String responseBody = response.body().string();

if (response.isSuccessful()) {
  JsonObject deepgramData = JsonParser.parseString(responseBody).getAsJsonObject();
  return successResponse(deepgramData);
} else {
  return errorResponse("Failed to transcribe video. " + responseBody);
}

}

private static JsonObject successResponse(JsonObject data) {
JsonObject response = new JsonObject();
response.addProperty("success", true);
response.add("deepgramData", data);
return response;
}

private static JsonObject errorResponse(String message) {
JsonObject response = new JsonObject();
response.addProperty("success", false);
response.addProperty("message", message);
return response;
}
}
This implementation uses the OkHttp library to make an HTTP request to the Deepgram API and transcribe the video. You'll need to set your Deepgram API key as an environment variable called DEEPGRAM_API_KEY. You can then call the deepgramTranscribeVideo() function with a JSON payload containing the fileUrl parameter to transcribe the video.This implementation uses the OkHttp library to make an HTTP request to the Deepgram API and transcribe the video. You'll need to set your Deepgram API key as an environment variable called DEEPGRAM_API_KEY. You can then call the deepgramTranscribeVideo() function with a JSON payload containing the fileUrl parameter to transcribe the video.

@ANUSHRAV01
Copy link

can u review this .I feel this can be the solution to your problem

@stnguyen90
Copy link
Contributor

@Faizan711, are you still working on this? If there's no response, I'll have to assign this to someone else.

@Faizan711
Copy link

Sorry @stnguyen90 i am currently unable to work on this, you can assign it to anybody else.

@stnguyen90 stnguyen90 assigned ANUSHRAV01 and unassigned Faizan711 Mar 1, 2023
@stnguyen90
Copy link
Contributor

@ANUSHRAV01, if you're still interested in working on this please submit a PR

@ANUSHRAV01
Copy link

Done ,@stnguyen90

@IMPranshu
Copy link

Please assign this to me. I have successfully implemented the function by taking reference from ruby folder.

@eldadfux
Copy link
Member

Thank you everyone for celebrating Hacktoberfest 22 with us! This issue will now be closed as we're getting ready to celebrate Hacktoberfest 23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

9 participants