#need deepgram demo code for help

1 messages · Page 1 of 1 (latest)

brave flume
#

Hi , is any deepgram demo client code availbale which help me to build my project

valid pumiceBOT
#

Hi @brave flume. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, Deepgram provides a variety of code samples for different languages. If you're interested in trying out making a Deepgram speech-to-text request in a specific language, you can check out their library of code samples on their Github repo (https://github.com/deepgram-devs/code-samples).

For instance, here is a Java example using OkHttpClient for a speech-to-text conversion using the Deepgram API:

package prerecorded.remote.okhttp3;

import okhttp3.*;

import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    // Replace "YOUR_API_KEY" with your actual API key
    String apiKey = "YOUR_DEEPGRAM_API_KEY";
    String url = "<https://api.deepgram.com/v1/listen";>
    String audioUrl = "<https://dpgr.am/spacewalk.wav";>

    // Create OkHttpClient instance
    OkHttpClient client = new OkHttpClient();

    // Create JSON request body
    MediaType mediaType = MediaType.parse("application/json");
    String json = "{\"url\": \"" + audioUrl + "\"}";
    RequestBody body = RequestBody.create(json, mediaType);

    // Create HTTP request
    Request request = new Request.Builder()
        .url(url)
        .post(body)
        .addHeader("Accept", "application/json")
        .addHeader("Authorization", "Token " + apiKey)
        .addHeader("Content-Type", "application/json")
        .build();

    // Execute the request and get the response
    Response response = client.newCall(request).execute();

    // Print the response body
    if (response.isSuccessful()) {
      System.out.println(response.body().string());
    } else {
      System.out.println("Request failed: " + response.code() + " - " + response.message());
    }
#

// Close the response
response.close();
}
}

This code is a simple example of how to use the Deepgram API to transcribe audio from a URL. You will need to replace `"YOUR_DEEPGRAM_API_KEY"` with your actual Deepgram API key.

You can find more examples and SDKs in different languages like JavaScript, Python, Go, and .NET in the **Deepgram Developer Documentation** (<https://developers.deepgram.com/docs/introduction>).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------