Skip to content

Commit

Permalink
Merge pull request #33 from AssemblyAI/E07417BDFEA3614F5967B1520F8B2F61
Browse files Browse the repository at this point in the history
Release 4.2.2
  • Loading branch information
Swimburger committed Jan 29, 2024
2 parents a88f2d4 + 458a085 commit e0855ad
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Changelog

## [4.2.2] - 2024-01-29

### Changed

- Windows paths passed to `client.transcripts.transcribe` and `client.transcripts.submit` will work as expected.

## [4.2.1] - 2024-01-23

### Added

- Add `answer_format` to `LemurActionItemsParams` type

### Changed

- Rename `RealtimeService` to `RealtimeTranscriber`, `RealtimeServiceFactory` to `RealtimeTranscriberFactory`, `RealtimeTranscriberFactory.createService()` to `RealtimeTranscriberFactory.transcriber()`. Deprecated aliases are provided for all old types and functions for backwards compatibility.
- Restrict the type for `redact_pii_audio_quality` from `string` to `RedactPiiAudioQuality` an enum string.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "assemblyai",
"version": "4.2.1",
"version": "4.2.2",
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
"engines": {
"node": ">=18"
Expand Down
12 changes: 1 addition & 11 deletions src/services/transcripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
SubmitParams,
} from "../..";
import { FileService } from "../files";
import { getPath } from "../../utils/path";

export class TranscriptService
extends BaseService
Expand Down Expand Up @@ -249,14 +250,3 @@ export class TranscriptService
);
}
}

function getPath(path: string) {
let url: URL;
try {
url = new URL(path);
if (url.protocol === "file:") return url.pathname;
else return null;
} catch {
return path;
}
}
7 changes: 7 additions & 0 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function getPath(path: string) {
if (path.startsWith("http")) return null;
if (path.startsWith("https")) return null;
if (path.startsWith("file://")) return path.substring(7);
if (path.startsWith("file:")) return path.substring(5);
return path;
}
28 changes: 28 additions & 0 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fetchMock from "jest-fetch-mock";
import { AssemblyAI } from "../src";
import { getPath } from "../src/utils/path";

fetchMock.enableMocks();

Expand All @@ -24,4 +25,31 @@ describe("utils", () => {
fetchMock.mockResponseOnce(JSON.stringify(error), { status: 500 });
await expect(() => assembly.transcripts.get("123")).rejects.toThrow(error);
});

it("should return correct path", () => {
const dict = [
["path/to/file", "path/to/file"],
["/path/to/file", "/path/to/file"],
["./path/to/file", "./path/to/file"],
["C:/path/to/file", "C:/path/to/file"],
["D:/path/to/file", "D:/path/to/file"],
["C:\\path\\to\\file", "C:\\path\\to\\file"],
["D:\\path\\to\\file", "D:\\path\\to\\file"],
["http://example.com", null],
["https://example.com", null],
["file://path/to/file", "path/to/file"],
["file://C:/path/to/file", "C:/path/to/file"],
["file://D:/path/to/file", "D:/path/to/file"],
["file:path/to/file", "path/to/file"],
["file:C:/path/to/file", "C:/path/to/file"],
["file:D:/path/to/file", "D:/path/to/file"],
["file:C:\\path\\to\\file", "C:\\path\\to\\file"],
["file:D:\\path\\to\\file", "D:\\path\\to\\file"],
["file://C:\\path\\to\\file", "C:\\path\\to\\file"],
["file://D:\\path\\to\\file", "D:\\path\\to\\file"],
];
for (const [input, output] of dict) {
expect(getPath(input as string)).toEqual(output);
}
});
});

0 comments on commit e0855ad

Please sign in to comment.