This commit is contained in:
MomentQYC 2024-10-07 09:04:06 +08:00
parent 167b1849f0
commit e17c3d1ef9
10 changed files with 64 additions and 30 deletions

View File

@ -78,6 +78,7 @@ function generateDummyUser(override?: Partial<MiUser>): MiUser {
isLocked: false, isLocked: false,
isBot: false, isBot: false,
isCat: true, isCat: true,
isVI: false,
isRoot: false, isRoot: false,
isExplorable: true, isExplorable: true,
isHibernated: false, isHibernated: false,
@ -197,6 +198,7 @@ function toPackedUserLite(user: MiUser, override?: Packed<'UserLite'>): Packed<'
})), })),
isBot: user.isBot, isBot: user.isBot,
isCat: user.isCat, isCat: user.isCat,
isVI: user.isVI,
emojis: user.emojis, emojis: user.emojis,
onlineStatus: 'active', onlineStatus: 'active',
badgeRoles: [], badgeRoles: [],

View File

@ -102,7 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
try { try {
const example = await fetch(instance.hfexampleAudioURL || ''); const example = await fetch(instance.hfexampleAudioURL || '');
exampleAudio = await example.blob(); exampleAudio = await example.blob();
} catch { } catch (e) {
throw new ApiError(meta.errors.unavailable); throw new ApiError(meta.errors.unavailable);
} }
@ -112,7 +112,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
try { try {
app = await Client.connect(instance.hfSpaceName, { hf_token: instance.hfAuthKey }); app = await Client.connect(instance.hfSpaceName, { hf_token: instance.hfAuthKey });
} catch { } catch (e) {
throw new ApiError(meta.errors.unavailable); throw new ApiError(meta.errors.unavailable);
} }
@ -135,19 +135,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
instance.hfdas, instance.hfdas,
]); ]);
} catch (e) { } catch (e) {
console.error("An error occurred during prediction:", e);
const responseMessage = (e as any).message || ((e as any).original_msg && (e as any).original_msg.message); const responseMessage = (e as any).message || ((e as any).original_msg && (e as any).original_msg.message);
if (responseMessage && responseMessage.includes('You have exceeded your GPU quota')) { if (responseMessage && responseMessage.includes('You have exceeded your GPU quota')) {
outofQuota = true; outofQuota = true;
console.log("Fallback to Inference API"); console.info("Fallback to Inference API");
}
notcontinue = true; notcontinue = true;
} else {
throw new ApiError(meta.errors.unavailable);
}
} }
if (!notcontinue) { if (!notcontinue) {
let resurl = result.data[0].url; const resurl = result.data[0].url;
const res = await this.httpRequestService.send(resurl, { const res = await this.httpRequestService.send(resurl, {
method: 'GET', method: 'GET',
@ -157,7 +157,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
timeout: 60000, timeout: 60000,
}); });
let contentType = res.headers.get('Content-Type') || 'application/octet-stream'; const contentType = res.headers.get('Content-Type') || 'application/octet-stream';
if (contentType === 'audio/x-wav') { if (contentType === 'audio/x-wav') {
return res.body; return res.body;
@ -183,7 +183,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
timeout: 60000, timeout: 60000,
}); });
let contentType = res.headers.get('Content-Type') || 'application/octet-stream'; const contentType = res.headers.get('Content-Type') || 'application/octet-stream';
if (contentType === 'audio/flac') { if (contentType === 'audio/flac') {
return res.body; return res.body;

View File

@ -80,16 +80,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="Slice by English punct">Slice by English punct</option> <option value="Slice by English punct">Slice by English punct</option>
<option value="Slice by every punct">Slice by every punct</option> <option value="Slice by every punct">Slice by every punct</option>
</MkSelect> </MkSelect>
<MkInput type="range" v-model.number="hftopK" :min="0" :max="100" :step="1"> <MkInput v-model.number="hftopK" type="range" :min="0" :max="100" :step="1">
<template #label>Set top_k Value: {{ hftopK }}</template> <template #label>Set top_k Value: {{ hftopK }}</template>
</MkInput> </MkInput>
<MkInput type="range" v-model.number="hftopP" :min="0" :max="100" :step="5"> <MkInput v-model.number="hftopP" type="range" :min="0" :max="100" :step="5">
<template #label>Set top_p Value: {{ hftopP }}</template> <template #label>Set top_p Value: {{ hftopP }}</template>
</MkInput> </MkInput>
<MkInput type="range" v-model.number="hfTemperature" :min="0" :max="100" :step="5"> <MkInput v-model.number="hfTemperature" type="range" :min="0" :max="100" :step="5">
<template #label>Set Temperature Value: {{ hfTemperature }}</template> <template #label>Set Temperature Value: {{ hfTemperature }}</template>
</MkInput> </MkInput>
<MkInput type="range" v-model.number="hfSpeedRate" :min="60" :max="165" :step="5"> <MkInput v-model.number="hfSpeedRate" type="range" :min="60" :max="165" :step="5">
<template #label>Set Speed Rate Value: {{ hfSpeedRate }}</template> <template #label>Set Speed Rate Value: {{ hfSpeedRate }}</template>
</MkInput> </MkInput>
</div> </div>

View File

@ -176,7 +176,7 @@ export function getNoteMenu(props: {
note: Misskey.entities.Note; note: Misskey.entities.Note;
translation: Ref<Misskey.entities.NotesTranslateResponse | null>; translation: Ref<Misskey.entities.NotesTranslateResponse | null>;
translating: Ref<boolean>; translating: Ref<boolean>;
convert: Ref<String | null>; convert: Ref<string | null>;
converting: Ref<boolean>; converting: Ref<boolean>;
isDeleted: Ref<boolean>; isDeleted: Ref<boolean>;
currentClip?: Misskey.entities.Clip; currentClip?: Misskey.entities.Clip;

View File

@ -1671,8 +1671,8 @@ declare namespace entities {
NotesTimelineResponse, NotesTimelineResponse,
NotesTranslateRequest, NotesTranslateRequest,
NotesTranslateResponse, NotesTranslateResponse,
NotesTTSRequest, NotesTtsRequest,
NotesTTSResponse, NotesTtsResponse,
NotesUnrenoteRequest, NotesUnrenoteRequest,
NotesUserListTimelineRequest, NotesUserListTimelineRequest,
NotesUserListTimelineResponse, NotesUserListTimelineResponse,
@ -2788,10 +2788,10 @@ type NotesTranslateRequest = operations['notes___translate']['requestBody']['con
type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json']; type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json'];
// @public (undocumented) // @public (undocumented)
type NotesTTSRequest = operations['notes___tts']['requestBody']['content']['application/json']; type NotesTtsRequest = operations['notes___tts']['requestBody']['content']['application/json'];
// @public (undocumented) // @public (undocumented)
type NotesTTSResponse = unknown; type NotesTtsResponse = operations['notes___tts']['responses']['200']['content']['application/json'];
// @public (undocumented) // @public (undocumented)
type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json']; type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json'];

View File

@ -3339,6 +3339,17 @@ declare module '../api.js' {
credential?: string | null, credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>; ): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *Yes* / **Permission**: *read:account*
*/
request<E extends 'notes/tts', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/** /**
* No description provided. * No description provided.
* *

View File

@ -450,8 +450,8 @@ import type {
NotesTimelineResponse, NotesTimelineResponse,
NotesTranslateRequest, NotesTranslateRequest,
NotesTranslateResponse, NotesTranslateResponse,
NotesTTSRequest, NotesTtsRequest,
NotesTTSResponse, NotesTtsResponse,
NotesUnrenoteRequest, NotesUnrenoteRequest,
NotesUserListTimelineRequest, NotesUserListTimelineRequest,
NotesUserListTimelineResponse, NotesUserListTimelineResponse,
@ -880,7 +880,7 @@ export type Endpoints = {
'notes/thread-muting/delete': { req: NotesThreadMutingDeleteRequest; res: EmptyResponse }; 'notes/thread-muting/delete': { req: NotesThreadMutingDeleteRequest; res: EmptyResponse };
'notes/timeline': { req: NotesTimelineRequest; res: NotesTimelineResponse }; 'notes/timeline': { req: NotesTimelineRequest; res: NotesTimelineResponse };
'notes/translate': { req: NotesTranslateRequest; res: NotesTranslateResponse }; 'notes/translate': { req: NotesTranslateRequest; res: NotesTranslateResponse };
'notes/tts': { req: NotesTTSRequest; res: NotesTTSResponse }; 'notes/tts': { req: NotesTtsRequest; res: NotesTtsResponse };
'notes/unrenote': { req: NotesUnrenoteRequest; res: EmptyResponse }; 'notes/unrenote': { req: NotesUnrenoteRequest; res: EmptyResponse };
'notes/user-list-timeline': { req: NotesUserListTimelineRequest; res: NotesUserListTimelineResponse }; 'notes/user-list-timeline': { req: NotesUserListTimelineRequest; res: NotesUserListTimelineResponse };
'notifications/create': { req: NotificationsCreateRequest; res: EmptyResponse }; 'notifications/create': { req: NotificationsCreateRequest; res: EmptyResponse };

View File

@ -453,8 +453,8 @@ export type NotesTimelineRequest = operations['notes___timeline']['requestBody']
export type NotesTimelineResponse = operations['notes___timeline']['responses']['200']['content']['application/json']; export type NotesTimelineResponse = operations['notes___timeline']['responses']['200']['content']['application/json'];
export type NotesTranslateRequest = operations['notes___translate']['requestBody']['content']['application/json']; export type NotesTranslateRequest = operations['notes___translate']['requestBody']['content']['application/json'];
export type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json']; export type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json'];
export type NotesTTSRequest = operations['notes___tts']['requestBody']['content']['application/json']; export type NotesTtsRequest = operations['notes___tts']['requestBody']['content']['application/json'];
export type NotesTTSResponse = unknown; export type NotesTtsResponse = operations['notes___tts']['responses']['200']['content']['application/json'];
export type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json']; export type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json'];
export type NotesUserListTimelineRequest = operations['notes___user-list-timeline']['requestBody']['content']['application/json']; export type NotesUserListTimelineRequest = operations['notes___user-list-timeline']['requestBody']['content']['application/json'];
export type NotesUserListTimelineResponse = operations['notes___user-list-timeline']['responses']['200']['content']['application/json']; export type NotesUserListTimelineResponse = operations['notes___user-list-timeline']['responses']['200']['content']['application/json'];

View File

@ -3745,6 +3745,7 @@ export type components = {
}[]; }[];
isBot?: boolean; isBot?: boolean;
isCat?: boolean; isCat?: boolean;
isVI?: boolean;
instance?: { instance?: {
name: string | null; name: string | null;
softwareName: string | null; softwareName: string | null;
@ -4777,7 +4778,7 @@ export type components = {
RoleCondFormulaValueUserSettingBooleanSchema: { RoleCondFormulaValueUserSettingBooleanSchema: {
id: string; id: string;
/** @enum {string} */ /** @enum {string} */
type: 'isSuspended' | 'isLocked' | 'isBot' | 'isCat' | 'isExplorable'; type: 'isSuspended' | 'isLocked' | 'isBot' | 'isCat' | 'isVI' | 'isExplorable';
}; };
RoleCondFormulaValueAssignedRole: { RoleCondFormulaValueAssignedRole: {
id: string; id: string;
@ -5010,7 +5011,7 @@ export type components = {
enableEmail: boolean; enableEmail: boolean;
enableServiceWorker: boolean; enableServiceWorker: boolean;
translatorAvailable: boolean; translatorAvailable: boolean;
TTSAvailable: boolean; ttsAvailable: boolean;
mediaProxy: string; mediaProxy: string;
enableUrlPreview: boolean; enableUrlPreview: boolean;
backgroundImageUrl: string | null; backgroundImageUrl: string | null;
@ -5126,7 +5127,7 @@ export type operations = {
enableEmail: boolean; enableEmail: boolean;
enableServiceWorker: boolean; enableServiceWorker: boolean;
translatorAvailable: boolean; translatorAvailable: boolean;
TTSAvailable: boolean; ttsAvailable: boolean;
silencedHosts?: string[]; silencedHosts?: string[];
mediaSilencedHosts: string[]; mediaSilencedHosts: string[];
pinnedUsers: string[]; pinnedUsers: string[];
@ -9516,6 +9517,27 @@ export type operations = {
langs?: string[]; langs?: string[];
deeplAuthKey?: string | null; deeplAuthKey?: string | null;
deeplIsPro?: boolean; deeplIsPro?: boolean;
hfAuthKey?: string | null;
/** @default false */
hfSpace?: boolean;
hfSpaceName?: string | null;
hfexampleAudioURL?: string | null;
hfexampleText?: string | null;
hfexampleLang?: string | null;
/** @default Slice once every 4 sentences */
hfslice?: string | null;
/** @default 15 */
hftopK?: number;
/** @default 100 */
hftopP?: number;
/** @default 100 */
hfTemperature?: number;
/** @default false */
hfnrm?: boolean;
/** @default 125 */
hfSpeedRate?: number;
/** @default false */
hfdas?: boolean;
enableEmail?: boolean; enableEmail?: boolean;
email?: string | null; email?: string | null;
smtpSecure?: boolean; smtpSecure?: boolean;
@ -19851,6 +19873,7 @@ export type operations = {
preventAiLearning?: boolean; preventAiLearning?: boolean;
isBot?: boolean; isBot?: boolean;
isCat?: boolean; isCat?: boolean;
isVI?: boolean;
injectFeaturedNote?: boolean; injectFeaturedNote?: boolean;
receiveAnnouncementEmail?: boolean; receiveAnnouncementEmail?: boolean;
alwaysMarkNsfw?: boolean; alwaysMarkNsfw?: boolean;
@ -23031,9 +23054,7 @@ export type operations = {
/** @description OK (with results) */ /** @description OK (with results) */
200: { 200: {
content: { content: {
'audio/flac': { 'application/json': string;
blob: Blob;
};
}; };
}; };
/** @description OK (without any results) */ /** @description OK (without any results) */