WIP
This commit is contained in:
parent
44f62160cb
commit
a481f00cab
|
@ -3544,10 +3544,18 @@ export interface Locale extends ILocale {
|
|||
* 翻訳
|
||||
*/
|
||||
"translate": string;
|
||||
/**
|
||||
* 変換
|
||||
*/
|
||||
"converting": string;
|
||||
/**
|
||||
* {x}から翻訳
|
||||
*/
|
||||
"translatedFrom": ParameterizedString<"x">;
|
||||
/**
|
||||
* {x}から変換
|
||||
*/
|
||||
"convertedFrom": ParameterizedString<"x">;
|
||||
/**
|
||||
* アカウントの削除が進行中です
|
||||
*/
|
||||
|
@ -6738,6 +6746,10 @@ export interface Locale extends ILocale {
|
|||
* 翻訳機能の利用
|
||||
*/
|
||||
"canUseTranslator": string;
|
||||
/**
|
||||
* TTS機能の利用
|
||||
*/
|
||||
"canUseTTS": string;
|
||||
/**
|
||||
* アイコンデコレーションの最大取付個数
|
||||
*/
|
||||
|
@ -7155,6 +7167,10 @@ export interface Locale extends ILocale {
|
|||
* Misskeyを翻訳
|
||||
*/
|
||||
"translation": string;
|
||||
/**
|
||||
* Misskeyを変換
|
||||
*/
|
||||
"convert": string;
|
||||
/**
|
||||
* Misskeyに寄付
|
||||
*/
|
||||
|
|
|
@ -882,7 +882,9 @@ learnMore: "詳しく"
|
|||
misskeyUpdated: "Misskeyが更新されました!"
|
||||
whatIsNew: "更新情報を見る"
|
||||
translate: "翻訳"
|
||||
converting: "変換"
|
||||
translatedFrom: "{x}から翻訳"
|
||||
convertedFrom: "{x}から変換"
|
||||
accountDeletionInProgress: "アカウントの削除が進行中です"
|
||||
usernameInfo: "サーバー上であなたのアカウントを一意に識別するための名前。アルファベット(a~z, A~Z)、数字(0~9)、およびアンダーバー(_)が使用できます。ユーザー名は後から変更することは出来ません。"
|
||||
aiChanMode: "藍モード"
|
||||
|
@ -1741,6 +1743,7 @@ _role:
|
|||
canHideAds: "広告の非表示"
|
||||
canSearchNotes: "ノート検索の利用"
|
||||
canUseTranslator: "翻訳機能の利用"
|
||||
canUseTTS: "TTS機能の利用"
|
||||
avatarDecorationLimit: "アイコンデコレーションの最大取付個数"
|
||||
_condition:
|
||||
roleAssignedTo: "マニュアルロールにアサイン済み"
|
||||
|
@ -1866,6 +1869,7 @@ _aboutMisskey:
|
|||
original: "オリジナル"
|
||||
thisIsModifiedVersion: "{name}はオリジナルのMisskeyを改変したバージョンを使用しています。"
|
||||
translation: "Misskeyを翻訳"
|
||||
convert: "Misskeyを変換"
|
||||
donate: "Misskeyに寄付"
|
||||
morePatrons: "他にも多くの方が支援してくれています。ありがとうございます🥰"
|
||||
patrons: "支援者"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class TTSIntegration1724683952000 {
|
||||
constructor() {
|
||||
this.name = 'TTSIntegration1724683952000';
|
||||
}
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" ADD "hfAuthKey" character varying(128)`);
|
||||
}
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "hfAuthKey"`);
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ export type RolePolicies = {
|
|||
canManageAvatarDecorations: boolean;
|
||||
canSearchNotes: boolean;
|
||||
canUseTranslator: boolean;
|
||||
canUseTTS: boolean;
|
||||
canHideAds: boolean;
|
||||
driveCapacityMb: number;
|
||||
alwaysMarkNsfw: boolean;
|
||||
|
@ -73,6 +74,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
|
|||
canManageAvatarDecorations: false,
|
||||
canSearchNotes: false,
|
||||
canUseTranslator: true,
|
||||
canUseTTS: true,
|
||||
canHideAds: false,
|
||||
driveCapacityMb: 100,
|
||||
alwaysMarkNsfw: false,
|
||||
|
@ -373,6 +375,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
canManageAvatarDecorations: calc('canManageAvatarDecorations', vs => vs.some(v => v === true)),
|
||||
canSearchNotes: calc('canSearchNotes', vs => vs.some(v => v === true)),
|
||||
canUseTranslator: calc('canUseTranslator', vs => vs.some(v => v === true)),
|
||||
canUseTTS: calc('canUseTTS', vs => vs.some(v => v === true)),
|
||||
canHideAds: calc('canHideAds', vs => vs.some(v => v === true)),
|
||||
driveCapacityMb: calc('driveCapacityMb', vs => Math.max(...vs)),
|
||||
alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),
|
||||
|
|
|
@ -121,6 +121,7 @@ export class MetaEntityService {
|
|||
enableServiceWorker: instance.enableServiceWorker,
|
||||
|
||||
translatorAvailable: instance.deeplAuthKey != null,
|
||||
ttsAvailable: instance.hfAuthKey != null,
|
||||
|
||||
serverRules: instance.serverRules,
|
||||
|
||||
|
|
|
@ -349,6 +349,12 @@ export class MiMeta {
|
|||
})
|
||||
public deeplIsPro: boolean;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
nullable: true,
|
||||
})
|
||||
public hfAuthKey: string | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
nullable: true,
|
||||
|
|
|
@ -203,6 +203,10 @@ export const packedMetaLiteSchema = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
ttsAvailable: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
mediaProxy: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
|
|
|
@ -216,6 +216,10 @@ export const packedRolePoliciesSchema = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
canUseTTS: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
canHideAds: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
|
|
|
@ -301,6 +301,7 @@ import * as ep___notes_threadMuting_create from './endpoints/notes/thread-muting
|
|||
import * as ep___notes_threadMuting_delete from './endpoints/notes/thread-muting/delete.js';
|
||||
import * as ep___notes_timeline from './endpoints/notes/timeline.js';
|
||||
import * as ep___notes_translate from './endpoints/notes/translate.js';
|
||||
import * as ep___notes_tts from './endpoints/notes/tts.js';
|
||||
import * as ep___notes_unrenote from './endpoints/notes/unrenote.js';
|
||||
import * as ep___notes_userListTimeline from './endpoints/notes/user-list-timeline.js';
|
||||
import * as ep___notifications_create from './endpoints/notifications/create.js';
|
||||
|
@ -684,6 +685,7 @@ const $notes_threadMuting_create: Provider = { provide: 'ep:notes/thread-muting/
|
|||
const $notes_threadMuting_delete: Provider = { provide: 'ep:notes/thread-muting/delete', useClass: ep___notes_threadMuting_delete.default };
|
||||
const $notes_timeline: Provider = { provide: 'ep:notes/timeline', useClass: ep___notes_timeline.default };
|
||||
const $notes_translate: Provider = { provide: 'ep:notes/translate', useClass: ep___notes_translate.default };
|
||||
const $notes_tts: Provider = { provide: 'ep:notes/tts', useClass: ep___notes_tts.default };
|
||||
const $notes_unrenote: Provider = { provide: 'ep:notes/unrenote', useClass: ep___notes_unrenote.default };
|
||||
const $notes_userListTimeline: Provider = { provide: 'ep:notes/user-list-timeline', useClass: ep___notes_userListTimeline.default };
|
||||
const $notifications_create: Provider = { provide: 'ep:notifications/create', useClass: ep___notifications_create.default };
|
||||
|
@ -1071,6 +1073,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
|
|||
$notes_threadMuting_delete,
|
||||
$notes_timeline,
|
||||
$notes_translate,
|
||||
$notes_tts,
|
||||
$notes_unrenote,
|
||||
$notes_userListTimeline,
|
||||
$notifications_create,
|
||||
|
@ -1452,6 +1455,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
|
|||
$notes_threadMuting_delete,
|
||||
$notes_timeline,
|
||||
$notes_translate,
|
||||
$notes_tts,
|
||||
$notes_unrenote,
|
||||
$notes_userListTimeline,
|
||||
$notifications_create,
|
||||
|
|
|
@ -307,6 +307,7 @@ import * as ep___notes_threadMuting_create from './endpoints/notes/thread-muting
|
|||
import * as ep___notes_threadMuting_delete from './endpoints/notes/thread-muting/delete.js';
|
||||
import * as ep___notes_timeline from './endpoints/notes/timeline.js';
|
||||
import * as ep___notes_translate from './endpoints/notes/translate.js';
|
||||
import * as ep___notes_tts from './endpoints/notes/tts.js';
|
||||
import * as ep___notes_unrenote from './endpoints/notes/unrenote.js';
|
||||
import * as ep___notes_userListTimeline from './endpoints/notes/user-list-timeline.js';
|
||||
import * as ep___notifications_create from './endpoints/notifications/create.js';
|
||||
|
@ -688,6 +689,7 @@ const eps = [
|
|||
['notes/thread-muting/delete', ep___notes_threadMuting_delete],
|
||||
['notes/timeline', ep___notes_timeline],
|
||||
['notes/translate', ep___notes_translate],
|
||||
['notes/tts', ep___notes_tts],
|
||||
['notes/unrenote', ep___notes_unrenote],
|
||||
['notes/user-list-timeline', ep___notes_userListTimeline],
|
||||
['notifications/create', ep___notifications_create],
|
||||
|
|
|
@ -118,6 +118,10 @@ export const meta = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
ttsAvailable: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
silencedHosts: {
|
||||
type: 'array',
|
||||
optional: true,
|
||||
|
@ -556,6 +560,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
enableEmail: instance.enableEmail,
|
||||
enableServiceWorker: instance.enableServiceWorker,
|
||||
translatorAvailable: instance.deeplAuthKey != null,
|
||||
ttsAvailable: instance.hfAuthKey != null,
|
||||
cacheRemoteFiles: instance.cacheRemoteFiles,
|
||||
cacheRemoteSensitiveFiles: instance.cacheRemoteSensitiveFiles,
|
||||
pinnedUsers: instance.pinnedUsers,
|
||||
|
|
|
@ -92,6 +92,7 @@ export const paramDef = {
|
|||
},
|
||||
deeplAuthKey: { type: 'string', nullable: true },
|
||||
deeplIsPro: { type: 'boolean' },
|
||||
hfAuthKey: { type: 'string', nullable: true },
|
||||
enableEmail: { type: 'boolean' },
|
||||
email: { type: 'string', nullable: true },
|
||||
smtpSecure: { type: 'boolean' },
|
||||
|
@ -506,6 +507,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
set.deeplIsPro = ps.deeplIsPro;
|
||||
}
|
||||
|
||||
if (ps.hfAuthKey !== undefined) {
|
||||
if (ps.hfAuthKey === '') {
|
||||
set.hfAuthKey = null;
|
||||
} else {
|
||||
set.hfAuthKey = ps.hfAuthKey;
|
||||
}
|
||||
}
|
||||
|
||||
if (ps.enableIpLogging !== undefined) {
|
||||
set.enableIpLogging = ps.enableIpLogging;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import { GetterService } from '@/server/api/GetterService.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
|
||||
requireCredential: true,
|
||||
kind: 'read:account',
|
||||
|
||||
res: {
|
||||
type: 'string',
|
||||
optional: true, nullable: false,
|
||||
contentMediaType: 'audio/flac',
|
||||
},
|
||||
|
||||
errors: {
|
||||
unavailable: {
|
||||
message: 'Convert of notes unavailable.',
|
||||
code: 'UNAVAILABLE',
|
||||
id: '97a0826c-6393-11ef-a650-67972d710975',
|
||||
},
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
code: 'NO_SUCH_NOTE',
|
||||
id: 'bea9b03f-36e0-49c5-a4db-627a029f8971',
|
||||
},
|
||||
cannotConvertInvisibleNote: {
|
||||
message: 'Cannot convert invisible note.',
|
||||
code: 'CANNOT_CONVERT_INVISIBLE_NOTE',
|
||||
id: 'f57caae0-6394-11ef-8e2a-d706932c1030',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
constructor(
|
||||
private noteEntityService: NoteEntityService,
|
||||
private getterService: GetterService,
|
||||
private metaService: MetaService,
|
||||
private httpRequestService: HttpRequestService,
|
||||
private roleService: RoleService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const policies = await this.roleService.getUserPolicies(me.id);
|
||||
if (!policies.canUseTTS) {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
|
||||
const note = await this.getterService.getNote(ps.noteId).catch(err => {
|
||||
if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (!(await this.noteEntityService.isVisibleForMe(note, me.id))) {
|
||||
throw new ApiError(meta.errors.cannotConvertInvisibleNote);
|
||||
}
|
||||
|
||||
if (note.text == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const instance = await this.metaService.fetch();
|
||||
|
||||
if (instance.hfAuthKey == null) {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
|
||||
const endpoint = 'https://api-inference.huggingface.co/models/suno/bark';
|
||||
|
||||
const res = await this.httpRequestService.send(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + instance.hfAuthKey,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
inputs: note.text,
|
||||
}),
|
||||
timeout: 60000,
|
||||
});
|
||||
|
||||
if (res.headers.get('content-type') === 'audio/flac') {
|
||||
return res.body;
|
||||
} else {
|
||||
throw new ApiError(meta.errors.unavailable);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -77,6 +77,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<Mfm :text="translation.text" :author="appearNote.user" :nyaize="'respect'" :emojiUrls="appearNote.emojis"/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="converting || convert" :class="$style.translation">
|
||||
<MkLoading v-if="converting" mini/>
|
||||
<div v-else-if="converturl">
|
||||
<!--<b>{{ i18n.tsx.convertedFrom({ x: appearNote.id }) }}: </b>-->
|
||||
<b>{{ 'From ' + appearNote.id }} </b>
|
||||
<MkMediaAudio :audio="converturl"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="appearNote.files && appearNote.files.length > 0">
|
||||
<MkMediaList ref="galleryEl" :mediaList="appearNote.files"/>
|
||||
|
@ -160,12 +168,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, inject, onMounted, ref, shallowRef, Ref, watch, provide } from 'vue';
|
||||
import { computed, inject, onMounted, ref, shallowRef, Ref, watch, provide, onUnmounted } from 'vue';
|
||||
import * as mfm from 'mfm-js';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import MkNoteSub from '@/components/MkNoteSub.vue';
|
||||
import MkNoteHeader from '@/components/MkNoteHeader.vue';
|
||||
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
||||
import MkMediaAudio from '@/components/MkMediaAudio.vue';
|
||||
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
|
||||
import MkReactionsViewerDetails from '@/components/MkReactionsViewer.details.vue';
|
||||
import MkMediaList from '@/components/MkMediaList.vue';
|
||||
|
@ -264,6 +273,9 @@ const muted = ref(checkMute(appearNote.value, $i?.mutedWords));
|
|||
const hardMuted = ref(props.withHardMute && checkMute(appearNote.value, $i?.hardMutedWords, true));
|
||||
const translation = ref<Misskey.entities.NotesTranslateResponse | null>(null);
|
||||
const translating = ref(false);
|
||||
const convert = ref<Blob | null>(null);
|
||||
const converting = ref(false);
|
||||
const converturl = ref<Misskey.entities.NotesTTSResponse | null>(null);
|
||||
const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.value.user.instance);
|
||||
const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i?.id));
|
||||
const renoteCollapsed = ref(
|
||||
|
@ -611,6 +623,25 @@ function emitUpdReaction(emoji: string, delta: number) {
|
|||
emit('reaction', emoji);
|
||||
}
|
||||
}
|
||||
|
||||
watch(convert, (newBlob) => {
|
||||
if (converturl.value && converturl.value.url) {
|
||||
URL.revokeObjectURL(converturl.value.url);
|
||||
}
|
||||
|
||||
if (newBlob) {
|
||||
converturl.value = { url: URL.createObjectURL(newBlob) };
|
||||
} else {
|
||||
converturl.value = null;
|
||||
}
|
||||
});
|
||||
console.log(converturl)
|
||||
|
||||
onUnmounted(() => {
|
||||
if (converturl.value && converturl.value.url) {
|
||||
URL.revokeObjectURL(converturl.value.url);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
|
|
@ -92,6 +92,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<Mfm :text="translation.text" :author="appearNote.user" :nyaize="'respect'" :emojiUrls="appearNote.emojis"/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="converting || convert" :class="$style.translation">
|
||||
<MkLoading v-if="converting" mini/>
|
||||
<div v-else-if="converturl">
|
||||
<!--<b>{{ i18n.tsx.convertedFrom({ x: appearNote.id }) }}: </b>-->
|
||||
<b>{{ 'From ' + appearNote.id }} </b>
|
||||
<MkMediaAudio :audio="converturl"/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="appearNote.files && appearNote.files.length > 0">
|
||||
<MkMediaList ref="galleryEl" :mediaList="appearNote.files"/>
|
||||
</div>
|
||||
|
@ -196,13 +204,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, inject, onMounted, provide, ref, shallowRef } from 'vue';
|
||||
import { computed, inject, onMounted, provide, ref, shallowRef, watch, onUnmounted } from 'vue';
|
||||
import * as mfm from 'mfm-js';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import MkNoteSub from '@/components/MkNoteSub.vue';
|
||||
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
||||
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
|
||||
import MkReactionsViewerDetails from '@/components/MkReactionsViewer.details.vue';
|
||||
import MkMediaAudio from '@/components/MkMediaAudio.vue';
|
||||
import MkMediaList from '@/components/MkMediaList.vue';
|
||||
import MkCwButton from '@/components/MkCwButton.vue';
|
||||
import MkPoll from '@/components/MkPoll.vue';
|
||||
|
@ -284,6 +293,9 @@ const isDeleted = ref(false);
|
|||
const muted = ref($i ? checkWordMute(appearNote.value, $i, $i.mutedWords) : false);
|
||||
const translation = ref<Misskey.entities.NotesTranslateResponse | null>(null);
|
||||
const translating = ref(false);
|
||||
const convert = ref<Blob | null>(null);
|
||||
const converting = ref(false);
|
||||
const converturl = ref<Misskey.entities.NotesTTSResponse | null>(null);
|
||||
const parsed = appearNote.value.text ? mfm.parse(appearNote.value.text) : null;
|
||||
const urls = parsed ? extractUrlFromMfm(parsed).filter((url) => appearNote.value.renote?.url !== url && appearNote.value.renote?.uri !== url) : null;
|
||||
const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.value.user.instance);
|
||||
|
@ -483,13 +495,13 @@ function onContextmenu(ev: MouseEvent): void {
|
|||
ev.preventDefault();
|
||||
react();
|
||||
} else {
|
||||
const { menu, cleanup } = getNoteMenu({ note: note.value, translating, translation, isDeleted });
|
||||
const { menu, cleanup } = getNoteMenu({ note: note.value, translating, translation, converting, convert, isDeleted });
|
||||
os.contextMenu(menu, ev).then(focus).finally(cleanup);
|
||||
}
|
||||
}
|
||||
|
||||
function showMenu(): void {
|
||||
const { menu, cleanup } = getNoteMenu({ note: note.value, translating, translation, isDeleted });
|
||||
const { menu, cleanup } = getNoteMenu({ note: note.value, translating, translation, converting, convert, isDeleted });
|
||||
os.popupMenu(menu, menuButton.value).then(focus).finally(cleanup);
|
||||
}
|
||||
|
||||
|
@ -544,6 +556,33 @@ function loadConversation() {
|
|||
conversation.value = res.reverse();
|
||||
});
|
||||
}
|
||||
|
||||
watch(convert, (newBlob) => {
|
||||
try {
|
||||
if (converturl.value && converturl.value.url) {
|
||||
URL.revokeObjectURL(converturl.value.url);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to revoke URL:', error);
|
||||
}
|
||||
|
||||
try {
|
||||
if (newBlob) {
|
||||
converturl.value = { url: URL.createObjectURL(newBlob) };
|
||||
} else {
|
||||
converturl.value = null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to create URL:', error);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (converturl.value && converturl.value.url) {
|
||||
URL.revokeObjectURL(converturl.value.url);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
|
|
@ -84,6 +84,7 @@ export const ROLE_POLICIES = [
|
|||
'canManageAvatarDecorations',
|
||||
'canSearchNotes',
|
||||
'canUseTranslator',
|
||||
'canUseTTS',
|
||||
'canHideAds',
|
||||
'driveCapacityMb',
|
||||
'alwaysMarkNsfw',
|
||||
|
|
|
@ -21,6 +21,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkSwitch>
|
||||
</div>
|
||||
</FormSection>
|
||||
<FormSection>
|
||||
<template #label>Text-To-Speech</template>
|
||||
|
||||
<div class="_gaps_m">
|
||||
<MkInput v-model="hfAuthKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>HuggingFace Auth Key</template>
|
||||
</MkInput>
|
||||
</div>
|
||||
</FormSection>
|
||||
</FormSuspense>
|
||||
</MkSpacer>
|
||||
<template #footer>
|
||||
|
@ -49,17 +59,20 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|||
|
||||
const deeplAuthKey = ref<string>('');
|
||||
const deeplIsPro = ref<boolean>(false);
|
||||
const hfAuthKey = ref<string>('');
|
||||
|
||||
async function init() {
|
||||
const meta = await misskeyApi('admin/meta');
|
||||
deeplAuthKey.value = meta.deeplAuthKey;
|
||||
deeplIsPro.value = meta.deeplIsPro;
|
||||
hfAuthKey.value = meta.hfAuthkey;
|
||||
}
|
||||
|
||||
function save() {
|
||||
os.apiWithDialog('admin/update-meta', {
|
||||
deeplAuthKey: deeplAuthKey.value,
|
||||
deeplIsPro: deeplIsPro.value,
|
||||
hfAuthKey: hfAuthKey.value,
|
||||
}).then(() => {
|
||||
fetchInstance(true);
|
||||
});
|
||||
|
|
|
@ -338,6 +338,26 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseTTS, 'canUseTTS'])">
|
||||
<template #label>{{ i18n.ts._role._options.canUseTTS }}</template>
|
||||
<template #suffix>
|
||||
<span v-if="role.policies.canUseTTS.useDefault" :class="$style.useDefaultLabel">{{ i18n.ts._role.useBaseValue }}</span>
|
||||
<span v-else>{{ role.policies.canUseTTS.value ? i18n.ts.yes : i18n.ts.no }}</span>
|
||||
<span :class="$style.priorityIndicator"><i :class="getPriorityIcon(role.policies.canUseTTS)"></i></span>
|
||||
</template>
|
||||
<div class="_gaps">
|
||||
<MkSwitch v-model="role.policies.canUseTTS.useDefault" :readonly="readonly">
|
||||
<template #label>{{ i18n.ts._role.useBaseValue }}</template>
|
||||
</MkSwitch>
|
||||
<MkSwitch v-model="role.policies.canUseTTS.value" :disabled="role.policies.canUseTTS.useDefault" :readonly="readonly">
|
||||
<template #label>{{ i18n.ts.enable }}</template>
|
||||
</MkSwitch>
|
||||
<MkRange v-model="role.policies.canUseTTS.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''">
|
||||
<template #label>{{ i18n.ts._role.priority }}</template>
|
||||
</MkRange>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.driveCapacity, 'driveCapacityMb'])">
|
||||
<template #label>{{ i18n.ts._role._options.driveCapacity }}</template>
|
||||
<template #suffix>
|
||||
|
|
|
@ -118,6 +118,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkSwitch>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseTTS, 'canSearchNotes'])">
|
||||
<template #label>{{ i18n.ts._role._options.canUseTTS }}</template>
|
||||
<template #suffix>{{ policies.canUseTTS ? i18n.ts.yes : i18n.ts.no }}</template>
|
||||
<MkSwitch v-model="policies.canUseTTS">
|
||||
<template #label>{{ i18n.ts.enable }}</template>
|
||||
</MkSwitch>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.driveCapacity, 'driveCapacityMb'])">
|
||||
<template #label>{{ i18n.ts._role._options.driveCapacity }}</template>
|
||||
<template #suffix>{{ policies.driveCapacityMb }}MB</template>
|
||||
|
|
|
@ -160,6 +160,8 @@ export function getNoteMenu(props: {
|
|||
note: Misskey.entities.Note;
|
||||
translation: Ref<Misskey.entities.NotesTranslateResponse | null>;
|
||||
translating: Ref<boolean>;
|
||||
convert: Ref<Blob | null>;
|
||||
converting: Ref<boolean>;
|
||||
isDeleted: Ref<boolean>;
|
||||
currentClip?: Misskey.entities.Clip;
|
||||
}) {
|
||||
|
@ -281,6 +283,20 @@ export function getNoteMenu(props: {
|
|||
props.translation.value = res;
|
||||
}
|
||||
|
||||
async function convert(): Promise<void> {
|
||||
if (props.convert.value != null) return;
|
||||
props.converting.value = true;
|
||||
const res = await misskeyApi('notes/tts', {
|
||||
noteId: appearNote.id,
|
||||
});
|
||||
if (res.headers.get('Content-Type')?.startsWith('audio/')) {
|
||||
props.convert.value = await res.blob();
|
||||
} else {
|
||||
console.error('API did not return audio data.');
|
||||
}
|
||||
props.converting.value = false;
|
||||
}
|
||||
|
||||
let menu: MenuItem[];
|
||||
if ($i) {
|
||||
const statePromise = misskeyApi('notes/state', {
|
||||
|
@ -321,6 +337,11 @@ export function getNoteMenu(props: {
|
|||
text: i18n.ts.translate,
|
||||
action: translate,
|
||||
} : undefined,
|
||||
$i && $i.policies.canUseTTS && instance.ttsAvailable ? {
|
||||
icon: 'ti ti-headphone',
|
||||
text: 'TTS',
|
||||
action: convert,
|
||||
} : undefined,
|
||||
{ type: 'divider' },
|
||||
statePromise.then(state => state.isFavorited ? {
|
||||
icon: 'ti ti-star-off',
|
||||
|
|
|
@ -1637,6 +1637,8 @@ declare namespace entities {
|
|||
NotesTimelineResponse,
|
||||
NotesTranslateRequest,
|
||||
NotesTranslateResponse,
|
||||
NotesTTSRequest,
|
||||
NotesTTSResponse,
|
||||
NotesUnrenoteRequest,
|
||||
NotesUserListTimelineRequest,
|
||||
NotesUserListTimelineResponse,
|
||||
|
@ -2686,6 +2688,12 @@ type NotesTranslateRequest = operations['notes___translate']['requestBody']['con
|
|||
// @public (undocumented)
|
||||
type NotesTranslateResponse = operations['notes___translate']['responses']['200']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type NotesTTSRequest = operations['notes___tts']['requestBody']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type NotesTTSResponse = operations['notes___tts']['responses']['200']['content']['audio/flac'];
|
||||
|
||||
// @public (undocumented)
|
||||
type NotesUnrenoteRequest = operations['notes___unrenote']['requestBody']['content']['application/json'];
|
||||
|
||||
|
|
|
@ -446,6 +446,8 @@ import type {
|
|||
NotesTimelineResponse,
|
||||
NotesTranslateRequest,
|
||||
NotesTranslateResponse,
|
||||
NotesTTSRequest,
|
||||
NotesTTSResponse,
|
||||
NotesUnrenoteRequest,
|
||||
NotesUserListTimelineRequest,
|
||||
NotesUserListTimelineResponse,
|
||||
|
@ -869,6 +871,7 @@ export type Endpoints = {
|
|||
'notes/thread-muting/delete': { req: NotesThreadMutingDeleteRequest; res: EmptyResponse };
|
||||
'notes/timeline': { req: NotesTimelineRequest; res: NotesTimelineResponse };
|
||||
'notes/translate': { req: NotesTranslateRequest; res: NotesTranslateResponse };
|
||||
'notes/tts': { req: NotesTTSRequest; res: NotesTTSResponse };
|
||||
'notes/unrenote': { req: NotesUnrenoteRequest; res: EmptyResponse };
|
||||
'notes/user-list-timeline': { req: NotesUserListTimelineRequest; res: NotesUserListTimelineResponse };
|
||||
'notifications/create': { req: NotificationsCreateRequest; res: EmptyResponse };
|
||||
|
@ -1251,6 +1254,7 @@ export const endpointReqTypes: Record<keyof Endpoints, 'application/json' | 'mul
|
|||
'notes/thread-muting/delete': 'application/json',
|
||||
'notes/timeline': 'application/json',
|
||||
'notes/translate': 'application/json',
|
||||
'notes/tts': 'application/json',
|
||||
'notes/unrenote': 'application/json',
|
||||
'notes/user-list-timeline': 'application/json',
|
||||
'notifications/create': 'application/json',
|
||||
|
|
|
@ -449,6 +449,8 @@ export type NotesTimelineRequest = operations['notes___timeline']['requestBody']
|
|||
export type NotesTimelineResponse = operations['notes___timeline']['responses']['200']['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 NotesTTSRequest = operations['notes___tts']['requestBody']['content']['application/json'];
|
||||
export type NotesTTSResponse = operations['notes___tts']['responses']['200']['content']['audio/flac'];
|
||||
export type NotesUnrenoteRequest = operations['notes___unrenote']['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'];
|
||||
|
|
|
@ -2852,6 +2852,15 @@ export type paths = {
|
|||
*/
|
||||
post: operations['notes___translate'];
|
||||
};
|
||||
'/notes/tts': {
|
||||
/**
|
||||
* notes/tts
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Credential required**: *Yes* / **Permission**: *read:account*
|
||||
*/
|
||||
post: operations['notes___tts'];
|
||||
};
|
||||
'/notes/unrenote': {
|
||||
/**
|
||||
* notes/unrenote
|
||||
|
@ -4787,6 +4796,7 @@ export type components = {
|
|||
canManageAvatarDecorations: boolean;
|
||||
canSearchNotes: boolean;
|
||||
canUseTranslator: boolean;
|
||||
canUseTTS: boolean;
|
||||
canHideAds: boolean;
|
||||
driveCapacityMb: number;
|
||||
alwaysMarkNsfw: boolean;
|
||||
|
@ -4932,6 +4942,7 @@ export type components = {
|
|||
enableEmail: boolean;
|
||||
enableServiceWorker: boolean;
|
||||
translatorAvailable: boolean;
|
||||
TTSAvailable: boolean;
|
||||
mediaProxy: string;
|
||||
enableUrlPreview: boolean;
|
||||
backgroundImageUrl: string | null;
|
||||
|
@ -5047,6 +5058,7 @@ export type operations = {
|
|||
enableEmail: boolean;
|
||||
enableServiceWorker: boolean;
|
||||
translatorAvailable: boolean;
|
||||
TTSAvailable: boolean;
|
||||
silencedHosts?: string[];
|
||||
mediaSilencedHosts: string[];
|
||||
pinnedUsers: string[];
|
||||
|
@ -22685,6 +22697,66 @@ export type operations = {
|
|||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* notes/tts
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Credential required**: *Yes* / **Permission**: *read:account*
|
||||
*/
|
||||
notes___tts: {
|
||||
requestBody: {
|
||||
content: {
|
||||
'application/json': {
|
||||
/** Format: misskey:id */
|
||||
noteId: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'audio/flac': {
|
||||
blob: Blob;
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description OK (without any results) */
|
||||
204: {
|
||||
content: never;
|
||||
};
|
||||
/** @description Client error */
|
||||
400: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Authentication error */
|
||||
401: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Forbidden error */
|
||||
403: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description I'm Ai */
|
||||
418: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Internal server error */
|
||||
500: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* notes/unrenote
|
||||
* @description No description provided.
|
||||
|
|
Loading…
Reference in New Issue