From 2cc6f10a4bdba9d97612766920a8939590ade476 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Tue, 10 Dec 2024 16:21:43 +0800 Subject: [PATCH] Add UI --- .../entry/src/main/ets/pages/Index.ets | 82 +++++++++++++++++-- .../main/resources/base/media/icon_doc.svg | 2 + .../main/resources/base/media/icon_mic.svg | 2 + .../src/main/resources/base/media/info.svg | 1 + .../entry/src/main/resources/rawfile/.gitkeep | 0 5 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_doc.svg create mode 100644 harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_mic.svg create mode 100644 harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/info.svg create mode 100644 harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/rawfile/.gitkeep diff --git a/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/ets/pages/Index.ets b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/ets/pages/Index.ets index 423b4276e..479471fbb 100644 --- a/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/ets/pages/Index.ets +++ b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/ets/pages/Index.ets @@ -1,17 +1,81 @@ +import { LengthUnit } from '@kit.ArkUI'; + @Entry @Component struct Index { - @State message: string = 'Hello World'; + @State title: string = 'Next-gen Kaldi: Speaker Diarization'; + @State titleFontSize: number = 15; + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + + @State resultForFile: string = ''; + @State resultForMic: string = ''; + + @State micBtnCaption: string = 'Start recording'; + @State micSaveBtnCaption: string = 'Save'; + + @Builder + TabBuilder(title: string, targetIndex: number, selectedImg: Resource, normalImg: Resource) { + Column() { + Image(this.currentIndex == targetIndex ? selectedImg : normalImg).size({ width: 25, height: 25 }) + Text(title).fontColor(this.currentIndex == targetIndex ? '#28bff1' : '#8a8a8a') + }.width('100%').height(50).justifyContent(FlexAlign.Center).onClick(() => { + this.currentIndex = targetIndex; + this.controller.changeIndex(this.currentIndex); + }) + } build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - } - .width('100%') + Column() { + Tabs({ barPosition: BarPosition.End, controller: this.controller }) { + TabContent() { + Column({space: 10}) { + Text(this.title).fontSize(this.titleFontSize).fontWeight(FontWeight.Bold); + Button('Select .wav file (16kHz) ') + + TextArea({ text: this.resultForFile }) + .lineSpacing({ value: 10, unit: LengthUnit.VP }) + .width('100%') + .height('100%') + } + }.tabBar(this.TabBuilder('From file', 0, $r('app.media.icon_doc'), $r('app.media.icon_doc'))) + + TabContent() { + Column({space: 10}) { + Text(this.title).fontSize(this.titleFontSize).fontWeight(FontWeight.Bold); + Row() { + Button(this.micBtnCaption) + + Button(this.micSaveBtnCaption) + } + TextArea({ text: this.resultForMic }) + .lineSpacing({ value: 10, unit: LengthUnit.VP }) + .width('100%') + .height('100%') + } + }.tabBar(this.TabBuilder('From mic', 1, $r('app.media.icon_mic'), $r('app.media.icon_mic'))) + + TabContent() { + Column({space: 10}) { + Text(this.title).fontSize(this.titleFontSize).fontWeight(FontWeight.Bold); + TextArea({ + text: ` +Everyting is open-sourced. + +It runs locally, without accessing the network + +See also https://github.com/k2-fsa/sherpa-onnx + +新一代 Kaldi QQ 和微信交流群: 请看 + +https://k2-fsa.github.io/sherpa/social-groups.html + +微信公众号: 新一代 Kaldi + ` + }).width('100%').height('100%').focusable(false) + }.justifyContent(FlexAlign.Start) + }.tabBar(this.TabBuilder('Help', 2, $r('app.media.info'), $r('app.media.info'))) + }.scrollable(false) } - .height('100%') } } \ No newline at end of file diff --git a/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_doc.svg b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_doc.svg new file mode 100644 index 000000000..ab6b1fd76 --- /dev/null +++ b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_doc.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_mic.svg b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_mic.svg new file mode 100644 index 000000000..0aeb30d63 --- /dev/null +++ b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/icon_mic.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/info.svg b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/info.svg new file mode 100644 index 000000000..2210223f4 --- /dev/null +++ b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/base/media/info.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/rawfile/.gitkeep b/harmony-os/SherpaOnnxSpeakerDiarization/entry/src/main/resources/rawfile/.gitkeep new file mode 100644 index 000000000..e69de29bb