Skip to content

Commit

Permalink
automate documentation for kapa
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraRodgers committed Jul 17, 2024
1 parent 770682f commit 3d72567
Show file tree
Hide file tree
Showing 21 changed files with 904 additions and 1,363 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Generate Documentation

on:
push:
branches:
- main

jobs:
generate-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements.txt
- name: Run generate_docs.py
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
python scripts/generate_docs.py
- name: Commit changes
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add .
git commit -m 'Update documentation with code samples and descriptions'
git push origin main
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ target/

**/bin/
**/obj/

#env
.env
58 changes: 58 additions & 0 deletions documentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Documentation

## Purpose

This directory contains markdown files of all the sample code found in this project's `/languages` folder. These markdown files are used by Deepgram's community knowledge AI tool to provide a knowledge base of code. Since the tool cannot read code in specific code language files, these markdown files have been created.

## Updating Languages

If you update one of the languages that already exists in this project (for example `javascript` or `python`), you must also update the corresponding markdown file in this directory. To do so, uncomment the language in the `update_languages.yaml` file. This will trigger a GitHub action that will update the markdown file when the updated code is merged into the `main` branch.

For example, if you update `javascript` and `python`, you will need to uncomment the following lines in the `update_languages.yaml` file:

```yaml
languages:
# - "c"
# - "cpp"
# - "csharp"
# - "go"
# - "java"
- "javascript"
# - "php"
- "python"
# - "ruby"
# - "rust"
# - "swift"
```

## Adding Languages

If you add a new language to this project, you will do the same thing as you did for updating an existing language. Simply add the language to the `update_languages.yaml` file.

For example, if you add `rust` as a new language folder, you will need to add the following lines to the `update_languages.yaml` file:

```yaml
languages:
# - "c"
# - "cpp"
# - "csharp"
# - "go"
# - "java"
# - "javascript"
# - "php"
# - "python"
# - "ruby"
- "rust"
# - "swift"
```

You must also add a config file inside the `/languages` folder. This config file will identify the target files to scrape. For example, if you add a new language called `rust`, you will need to create a config file called `rust.yaml` inside the `/languages/rust` folder. The config file should look like this:

```yaml
target_files:
- "*.rs"
```
## Output
If you have followed the steps above, you can expect to see an updated or newly-created markdown file in the documentation directory after your code is merged into the `main` branch.
24 changes: 24 additions & 0 deletions documentation/c-readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Speech-to-Text Conversion using Deepgram API with C and libcurl

**Title:** Converting Local Audio File to Text using Deepgram API

**Code Sample:** speech-to-text/prerecorded/local/libcurl/c_local.c

**Description:** This C program uses the libcurl library to send a local audio file to the Deepgram API for speech-to-text conversion. The code initializes libcurl, sets request headers, reads the audio file into a buffer, and sends the audio data to the Deepgram API. It then checks for errors and cleans up.

### speech-to-text/prerecorded/local/libcurl/c_local.c

```c
Expand Down Expand Up @@ -67,6 +75,14 @@ int main(void) {

```
## Speech-to-Text Conversion using Deepgram API with libcurl in C
**Title:** Converting Remote Pre-recorded Speech to Text
**Code Sample:** speech-to-text/prerecorded/remote/libcurl/c_remote.c
**Description:** This C code uses the libcurl library to send a HTTP request to the Deepgram API. It sets the necessary headers and sends a JSON payload containing the URL of a pre-recorded audio file. The Deepgram API then processes this audio file and returns a transcription.
### speech-to-text/prerecorded/remote/libcurl/c_remote.c
```c
Expand Down Expand Up @@ -113,6 +129,14 @@ int main(void) {
```

## Text-to-Speech Conversion using Deepgram API and libcurl in C

**Title:** Converting Text to Speech Using Deepgram API and libcurl in C

**Code Sample:** text-to-speech/libcurl/c_tts.c

**Description:** This C code uses the Deepgram API and the libcurl library to convert a hardcoded text string into speech. The output is saved as an MP3 file. The program initializes libcurl, sets the request headers, URL, and data, performs the request, and then cleans up.

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

```c
Expand Down
24 changes: 24 additions & 0 deletions documentation/cpp-readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Speech-to-Text Conversion using Deepgram API with Local Audio File and libcurl in C++

**Title:** Converting Local Audio File to Text using Deepgram API and libcurl in C++

**Code Sample:** speech-to-text/prerecorded/local/libcurl/cplus_local.cpp

**Description:** This C++ code uses the libcurl library to send a local audio file to the Deepgram API for speech-to-text conversion. It initializes libcurl, sets the request URL and headers, reads the audio file as binary data, and sends it as the request data. It then performs the request and checks for any errors.

### speech-to-text/prerecorded/local/libcurl/cplus_local.cpp

```cpp
Expand Down Expand Up @@ -64,6 +72,14 @@ int main() {

```

## Speech-to-Text Conversion using Deepgram API with C++ and libcurl

**Title:** Speech-to-Text Conversion for Remote Pre-recorded Audio Files

**Code Sample:** speech-to-text/prerecorded/remote/libcurl/cplus_remote.cpp

**Description:** This C++ code uses the libcurl library to send a HTTP request to Deepgram's API. It converts a remote pre-recorded audio file (specified by a URL) into text. The code includes initialization of libcurl, setting request URL and headers, performing the request and error checking.

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

```cpp
Expand Down Expand Up @@ -113,6 +129,14 @@ int main() {

```

## Text-to-Speech Conversion using Deepgram API in C++

**Title:** Text-to-Speech Conversion with Deepgram API

**Code Sample:** text-to-speech/libcurl/cplus_tts.cpp

**Description:** This C++ code uses the libcurl library and Deepgram API to convert text into speech. It sends a HTTP request to the Deepgram API with the text to be converted and saves the response (the speech version of the text) as an MP3 file.

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

```cpp
Expand Down
93 changes: 93 additions & 0 deletions documentation/csharp-readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Speech-to-Text Conversion using Deepgram API

**Title:** Converting Pre-recorded Audio to Text using HTTP Client in C#

**Code Sample:** speech-to-text/prerecorded/local/httpclient/Program.cs

**Description:** This C# code uses the Deepgram API to convert a pre-recorded audio file to text. It reads the audio file as binary data, sends it to the Deepgram API, and then outputs the transcribed text. The code also handles errors and unsuccessful requests.

### speech-to-text/prerecorded/local/httpclient/Program.cs

```csharp
Expand Down Expand Up @@ -48,6 +56,14 @@ class Program

```

## Assembly Attributes Setting for .NET Core Application

**Title:** Setting Assembly Attributes in .NET Core

**Code Sample:** speech-to-text/prerecorded/local/httpclient/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs

**Description:** This code sets the assembly attributes for a .NET Core application. It specifies that the target framework for the application is .NET Core 7.0.

### speech-to-text/prerecorded/local/httpclient/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs

```csharp
Expand All @@ -58,6 +74,14 @@ using System.Reflection;

```

## Assembly Information for Local_HttpClient

**Title:** Assembly Information Configuration

**Code Sample:** speech-to-text/prerecorded/local/httpclient/obj/Debug/net7.0/Local_HttpClient.AssemblyInfo.cs

**Description:** This auto-generated code provides assembly information for a Local_HttpClient application. It includes details like company name, product name, assembly version, and configuration settings. Changes to this file may affect the application's behavior.

### speech-to-text/prerecorded/local/httpclient/obj/Debug/net7.0/Local_HttpClient.AssemblyInfo.cs

```csharp
Expand Down Expand Up @@ -86,6 +110,14 @@ using System.Reflection;

```

## Global Usings for HttpClient in Speech-to-Text Conversion

**Title:** Global Namespace Declarations for Speech-to-Text Conversion

**Code Sample:** speech-to-text/prerecorded/local/httpclient/obj/Debug/net7.0/Local_HttpClient.GlobalUsings.g.cs

**Description:** This code defines global namespaces that are used throughout the application for a speech-to-text conversion program. It includes System, IO, Linq, HttpClient, and threading libraries.

### speech-to-text/prerecorded/local/httpclient/obj/Debug/net7.0/Local_HttpClient.GlobalUsings.g.cs

```csharp
Expand All @@ -100,6 +132,14 @@ global using global::System.Threading.Tasks;

```

## Speech-to-Text Conversion using Deepgram API with HttpClient

**Title:** Converting Pre-recorded Remote Audio to Text using HttpClient in C#

**Code Sample:** speech-to-text/prerecorded/remote/httpclient/Program.cs

**Description:** This C# program uses the HttpClient class to send a POST request to the Deepgram API. It converts a pre-recorded remote audio file (spacewalk.wav) into text and prints the response. If an error occurs, it prints the status code.

### speech-to-text/prerecorded/remote/httpclient/Program.cs

```csharp
Expand Down Expand Up @@ -143,6 +183,14 @@ class Program

```

## .NET 7.0 Assembly Attributes Declaration

**Title:** Assembly Attributes for .NET 7.0

**Code Sample:** speech-to-text/prerecorded/remote/httpclient/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs

**Description:** This code is auto-generated and sets the target framework for a .NET 7.0 application. It uses the System.Runtime.Versioning.TargetFrameworkAttribute to specify the version and display name of the framework.

### speech-to-text/prerecorded/remote/httpclient/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs

```csharp
Expand All @@ -153,6 +201,14 @@ using System.Reflection;

```

## Global Usings in .NET 7.0 for HttpClient in Speech-to-Text Conversion

**Title:** Global Usings for Speech-to-Text Conversion with HttpClient

**Code Sample:** speech-to-text/prerecorded/remote/httpclient/obj/Debug/net7.0/Remote_HttpClient.GlobalUsings.g.cs

**Description:** This auto-generated code declares global usings for various .NET classes. It simplifies the code in the rest of the application by allowing these classes to be used without specifying their namespaces each time. The classes include System, IO, Linq, HttpClient, and threading-related classes, which are commonly used in speech-to-text conversion applications.

### speech-to-text/prerecorded/remote/httpclient/obj/Debug/net7.0/Remote_HttpClient.GlobalUsings.g.cs

```csharp
Expand All @@ -167,6 +223,14 @@ global using global::System.Threading.Tasks;

```

## Assembly Information for Remote HttpClient

**Title:** Assembly Information for Remote HttpClient

**Code Sample:** speech-to-text/prerecorded/remote/httpclient/obj/Debug/net7.0/Remote_HttpClient.AssemblyInfo.cs

**Description:** This auto-generated code provides assembly information for a Remote HttpClient application. It includes details such as company, configuration, product, title, and version attributes. Any changes to this file may cause incorrect behavior and will be lost if the code is regenerated.

### speech-to-text/prerecorded/remote/httpclient/obj/Debug/net7.0/Remote_HttpClient.AssemblyInfo.cs

```csharp
Expand Down Expand Up @@ -195,6 +259,14 @@ using System.Reflection;

```

## Text-to-Speech Conversion Using Deepgram API

**Title:** Converting Text to Speech using Deepgram API in C#

**Code Sample:** text-to-speech/httpclient/Program.cs

**Description:** This C# code sample uses the Deepgram API to convert a text string into speech. The resultant audio is then saved as an MP3 file. The HttpClient class is used to send a POST request to the Deepgram API, and the response is streamed into a binary file. The API key and output file path are configurable.

### text-to-speech/httpclient/Program.cs

```csharp
Expand Down Expand Up @@ -258,6 +330,14 @@ class Program
}
```

## .NET Core 7.0 Assembly Attributes Configuration

**Title:** Setting Target Framework for .NET Core 7.0

**Code Sample:** text-to-speech/httpclient/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs

**Description:** This code sets the target framework for a .NET Core application to version 7.0 by using the TargetFrameworkAttribute in the System.Runtime.Versioning namespace.

### text-to-speech/httpclient/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs

```csharp
Expand All @@ -268,6 +348,12 @@ using System.Reflection;

```

**Title:** Global Usings in Text-to-Speech HttpClient Application

**Code Sample:** text-to-speech/httpclient/obj/Debug/net7.0/TTS_HttpClient.GlobalUsings.g.cs

**Description:** This code defines global usings for a Text-to-Speech application using HttpClient. It includes libraries for handling system operations, I/O, LINQ, HTTP requests, and asynchronous programming.

### text-to-speech/httpclient/obj/Debug/net7.0/TTS_HttpClient.GlobalUsings.g.cs

```csharp
Expand All @@ -282,6 +368,13 @@ global using global::System.Threading.Tasks;

```

## Assembly Information for Text-to-Speech HttpClient

**Title:** Assembly Attributes for TTS_HttpClient
**Code Sample:** text-to-speech/httpclient/obj/Debug/net7.0/TTS_HttpClient.AssemblyInfo.cs

**Description:** This auto-generated code provides assembly information for a Text-to-Speech HttpClient, including company, configuration, file version, informational version, product, title, and version attributes. It is generated by MSBuild WriteCodeFragment class.

### text-to-speech/httpclient/obj/Debug/net7.0/TTS_HttpClient.AssemblyInfo.cs

```csharp
Expand Down
Loading

0 comments on commit 3d72567

Please sign in to comment.