Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ xcuserdata/
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

# Config files
Playground/Resources/config.json
10 changes: 8 additions & 2 deletions Playground.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
74F3B7C12E1CF4F400C544D1 /* AudioProcess.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F3B7C02E1CF4F400C544D1 /* AudioProcess.swift */; };
74F860942E29A9D20007163C /* ProcessTapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F860932E29A9D20007163C /* ProcessTapper.swift */; };
74F860962E2B19060007163C /* CoreAudioUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F860952E2B19060007163C /* CoreAudioUtils.swift */; };
AD7653122E43104600DF15D1 /* config.json in Resources */ = {isa = PBXBuildFile; fileRef = AD7653112E43104600DF15D1 /* config.json */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -79,6 +80,7 @@
74F3B7C02E1CF4F400C544D1 /* AudioProcess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioProcess.swift; sourceTree = "<group>"; };
74F860932E29A9D20007163C /* ProcessTapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessTapper.swift; sourceTree = "<group>"; };
74F860952E2B19060007163C /* CoreAudioUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreAudioUtils.swift; sourceTree = "<group>"; };
AD7653112E43104600DF15D1 /* config.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = config.json; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -121,6 +123,7 @@
1677AFD72B576375008C61C0 /* Resources */ = {
isa = PBXGroup;
children = (
AD7653112E43104600DF15D1 /* config.json */,
1677AFE02B57678E008C61C0 /* Assets.xcassets */,
1677AFA92B57618A008C61C0 /* Playground.entitlements */,
);
Expand Down Expand Up @@ -270,6 +273,7 @@
buildActionMask = 2147483647;
files = (
1677AFC42B57618A008C61C0 /* Preview Assets.xcassets in Resources */,
AD7653122E43104600DF15D1 /* config.json in Resources */,
7469F1FA2E3AC3D00090AEBA /* README.md in Resources */,
1677AFE12B57678E008C61C0 /* Assets.xcassets in Resources */,
);
Expand Down Expand Up @@ -438,7 +442,7 @@
DEAD_CODE_STRIPPING = YES;
DEPLOYMENT_POSTPROCESSING = NO;
DEVELOPMENT_ASSET_PATHS = "\"Playground/Preview Content\"";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 2A7SXV3WJH;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
EXCLUDED_SOURCE_FILE_NAMES = "GoogleService-Info.plist";
Expand All @@ -465,6 +469,7 @@
MACOSX_DEPLOYMENT_TARGET = 14.2;
MARKETING_VERSION = 0.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.argmaxinc.example.Playground${DEVELOPMENT_TEAM}";
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.argmaxinc.example.Playground;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Xcode generated this part

PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = auto;
Expand All @@ -490,7 +495,7 @@
DEAD_CODE_STRIPPING = YES;
DEPLOYMENT_POSTPROCESSING = NO;
DEVELOPMENT_ASSET_PATHS = "\"Playground/Preview Content\"";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 2A7SXV3WJH;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove your development team :)

ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
EXCLUDED_SOURCE_FILE_NAMES = "GoogleService-Info-Dev.plist";
Expand All @@ -517,6 +522,7 @@
MACOSX_DEPLOYMENT_TARGET = 14.2;
MARKETING_VERSION = 0.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.argmaxinc.example.Playground${DEVELOPMENT_TEAM}";
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.argmaxinc.example.Playground;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = auto;
Expand Down
33 changes: 30 additions & 3 deletions Playground/Environment/DefaultEnvInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,43 @@ import ArgmaxSecrets
public class DefaultEnvInitializer: PlaygroundEnvInitializer {

public func createAPIKeyProvider() -> APIKeyProvider {
return PlainTextAPIKeyProvider(
apiKey: "" // TODO: Add your WhisperKitPro API key here
)
return loadAPIKeyProviderFromConfig()
}

private func loadAPIKeyProviderFromConfig() -> APIKeyProvider {
guard let configURL = Bundle.main.url(forResource: "config", withExtension: "json") else {
print("Warning: config.json not found. Using default API key.")
return PlainTextAPIKeyProvider(
apiKey: "" // Fallback API key
)
}

do {
let configData = try Data(contentsOf: configURL)
let config = try JSONDecoder().decode(Config.self, from: configData)
return PlainTextAPIKeyProvider(
apiKey: config.apiKey,
huggingFaceToken: config.huggingFaceToken
)
} catch {
print("Warning: Failed to load config.json: \(error). Using default API key.")
return PlainTextAPIKeyProvider(
apiKey: "" // Fallback API key
)
}
}

public func createAnalyticsLogger() -> AnalyticsLogger {
return NoOpAnalyticsLogger()
}
}

/// Configuration structure for API keys
private struct Config: Codable {
let apiKey: String
let huggingFaceToken: String?
}

/// A simple API key provider that stores keys as plain text.
///
/// This provider is suitable for development and testing but should not be used
Expand Down
4 changes: 4 additions & 0 deletions Playground/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
</dict>
</plist>
4 changes: 4 additions & 0 deletions Playground/Resources/config.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"apiKey": "YOUR_API_KEY_HERE",
"huggingFaceToken": null
}
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,28 @@ In Xcode, select your app target and go to **Signing & Capabilities**. Choose yo
### 2. Add Your API Key
In order to unlock the SDK, you will need to provide your API key. You can create one at [https://app.argmaxinc.com](https://app.argmaxinc.com).

In `DefaultEnvInitializer.swift`, update the following code with your credentials:
#### Option 1: Using Configuration File (Recommended)
1. Copy the template configuration file:
```bash
cp Playground/Resources/config.template.json Playground/Resources/config.json
```
2. Edit `Playground/Resources/config.json` and replace `YOUR_API_KEY_HERE` with your actual API key:
```json
{
"apiKey": "your_actual_api_key_here",
"huggingFaceToken": null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just open sourced our huggingface repo, so huggingfacetoken is no longer needded, we can remove this field

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I also removed huggingFaceToken form the PlainTextAPIKeyProvider now

}
```

The `config.json` file is already added to `.gitignore` to prevent accidentally committing your API key.

#### Option 2: Direct Code Modification
Alternatively, you can modify the fallback API key in `DefaultEnvInitializer.swift`:

```swift
public class DefaultEnvInitializer: PlaygroundEnvInitializer {

public func createAPIKeyProvider() -> APIKeyProvider {
return PlainTextAPIKeyProvider(
apiKey: "", // TODO: Add your Argmax SDK API key
)
}
}
return PlainTextAPIKeyProvider(
apiKey: "your_api_key_here" // Fallback API key
)
```

> **Do not commit your API key.**.
> **Important**: Never commit your actual API key to version control.