Skip to content

Commit

Permalink
working on automation
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraRodgers committed Jul 17, 2024
1 parent ad243a0 commit 770682f
Show file tree
Hide file tree
Showing 636 changed files with 176,549 additions and 0 deletions.
163 changes: 163 additions & 0 deletions documentation/c-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
### speech-to-text/prerecorded/local/libcurl/c_local.c

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
CURL *curl;
CURLcode res;

// Initialize libcurl
curl = curl_easy_init();
if(curl) {
// Set the request headers
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Token DEEPGRAM_API_KEY"); // Replace DEEPGRAM_API_KEY with your actual API key
headers = curl_slist_append(headers, "Content-Type: audio/wav");

// Set the request URL
curl_easy_setopt(curl, CURLOPT_URL, "https://api.deepgram.com/v1/listen");
// Set the request headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

// Set the request data
FILE *file = fopen("youraudio.wav", "rb"); // Replace "youraudio.wav" with the path to your audio file
if (!file) {
fprintf(stderr, "Error: Unable to open audio file\n");
return 1;
}
fseek(file, 0, SEEK_END);
long file_size = ftell(file);
rewind(file);
char *buffer = malloc(file_size);
if (!buffer) {
fprintf(stderr, "Error: Memory allocation failed\n");
fclose(file);
return 1;
}
if (fread(buffer, 1, file_size, file) != file_size) {
fprintf(stderr, "Error: Failed to read audio file\n");
fclose(file);
free(buffer);
return 1;
}
fclose(file);

// Set the request data as binary
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, file_size);

// Perform the request
res = curl_easy_perform(curl);
// Check for errors
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));

// Cleanup
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
free(buffer);
}
return 0;
}

```
### speech-to-text/prerecorded/remote/libcurl/c_remote.c
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
int main(void) {
CURL *curl;
CURLcode res;
// Initialize libcurl
curl = curl_easy_init();
if(curl) {
// Set the request headers
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Token DEEPGRAM_API_KEY"); // Replace DEEPGRAM_API_KEY with your actual API key
headers = curl_slist_append(headers, "Content-Type: application/json");
// Set the request URL
curl_easy_setopt(curl, CURLOPT_URL, "https://api.deepgram.com/v1/listen");
// Set the request headers
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
// Set the request data
const char *json_data = "{\"url\": \"https://dpgr.am/spacewalk.wav\"}"; // Replace with remote file URL
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data);
// Perform the request
res = curl_easy_perform(curl);
// Check for errors
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
// Cleanup
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}
```

### text-to-speech/libcurl/c_tts.c

```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
CURL *curl;
CURLcode res;

// Initialize libcurl
curl = curl_easy_init();
if(curl) {
// Set the request headers
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Token DEEPGRAM_API_KEY"); // Replace DEEPGRAM_API_KEY with your actual API key
headers = curl_slist_append(headers, "Content-Type: application/json");

// Set the request URL and add model choice
curl_easy_setopt(curl, CURLOPT_URL, "https://api.deepgram.com/v1/speak?model=aura-asteria-en");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

// Set the request data
const char *data = "{\"text\": \"Hello, how can I help you today?\"}"; // JSON data
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

FILE *file = fopen("your_output_file.mp3", "wb"); // Replace "your_output_file.mp3" with the path to your output file
if (!file) {
fprintf(stderr, "Error: Unable to open output file\n");
return 1;
}
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);

res = curl_easy_perform(curl);
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));

curl_slist_free_all(headers);
curl_easy_cleanup(curl);
fclose(file);
}
return 0;
}

```
158 changes: 158 additions & 0 deletions documentation/cpp-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
### speech-to-text/prerecorded/local/libcurl/cplus_local.cpp

```cpp
#include <iostream>
#include <curl/curl.h>
#include <fstream>
#include <string>

int main() {
// Initialize libcurl
curl_global_init(CURL_GLOBAL_ALL);

// Create a CURL handle
CURL *curl = curl_easy_init();
if (curl) {
// Set the request URL
curl_easy_setopt(curl, CURLOPT_URL, "https://api.deepgram.com/v1/listen");

// Set the request headers
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Token DEEPGRAM_API_KEY"); // Replace YOUR_DEEPGRAM_API_KEY with your actual API key
headers = curl_slist_append(headers, "Content-Type: audio/wav");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

// Read the audio file as binary data
std::ifstream file("youraudio.wav", std::ios::binary | std::ios::ate);
if (!file.is_open()) {
std::cerr << "Failed to open audio file" << std::endl;
return 1;
}
std::streamsize file_size = file.tellg();
file.seekg(0, std::ios::beg);
std::string audio_data(file_size, '\0');
if (!file.read(&audio_data[0], file_size)) {
std::cerr << "Failed to read audio file" << std::endl;
return 1;
}
file.close();

// Set the request data as binary
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, audio_data.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, audio_data.size());

// Perform the request
CURLcode res = curl_easy_perform(curl);

// Check for errors
if (res != CURLE_OK) {
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
}

// Cleanup
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
} else {
std::cerr << "Failed to initialize libcurl" << std::endl;
}

// Cleanup libcurl
curl_global_cleanup();

return 0;
}

```

### speech-to-text/prerecorded/remote/libcurl/cplus_remote.cpp

```cpp
#include <iostream>
#include <curl/curl.h>

int main() {
// Initialize libcurl
curl_global_init(CURL_GLOBAL_ALL);

// Create a CURL handle
CURL *curl = curl_easy_init();
if (curl) {
// Set the request URL
curl_easy_setopt(curl, CURLOPT_URL, "https://api.deepgram.com/v1/listen");

// Set the request headers
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Token DEEPGRAM_API_KEY"); // Replace YOUR_DEEPGRAM_API_KEY with your actual API key
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

// Set the request data
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"url\": \"https://dpgr.am/spacewalk.wav\"}"); // Replace https://dpgr.am/spacewalk.wav with the actual URL of the audio file

// Perform the request
CURLcode res = curl_easy_perform(curl);

// Check for errors
if (res != CURLE_OK) {
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
}

// Cleanup
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
} else {
std::cerr << "Failed to initialize libcurl" << std::endl;
}

// Cleanup libcurl
curl_global_cleanup();

return 0;
}

```

### text-to-speech/libcurl/cplus_tts.cpp

```cpp
#include <iostream>
#include <curl/curl.h>

int main() {
CURL *curl;
CURLcode res;

curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.deepgram.com/v1/speak?model=aura-asteria-en");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Token DEEPGRAM_API_KEY"); // Replace YOUR_DEEPGRAM_API_KEY with your actual API key
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"text\": \"Hello, how can I help you today?\"}");

FILE *fp = fopen("your_output_file.mp3", "wb");
if (fp == NULL) {
std::cerr << "Failed to create output file." << std::endl;
return 1;
}

curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);

res = curl_easy_perform(curl);

curl_slist_free_all(headers);
curl_easy_cleanup(curl);
fclose(fp);

if(res != CURLE_OK)
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
}
return 0;
}

```

Loading

0 comments on commit 770682f

Please sign in to comment.