mirror of
https://codeberg.org/aryak/mozhi
synced 2024-11-18 10:42:58 +05:30
imgtxt was dumb
This commit is contained in:
parent
d7fc768109
commit
f7dc568f72
@ -21,7 +21,6 @@ Just `go build` and you're done :D
|
|||||||
## Features
|
## Features
|
||||||
- An all mode where the responses of all supported engines will be shown.
|
- An all mode where the responses of all supported engines will be shown.
|
||||||
- Autodetect which will show the language that was detected
|
- Autodetect which will show the language that was detected
|
||||||
- Tesseract based image recognition (it isn't that good to be fair but it works nontheless)
|
|
||||||
- Text-To-Speech for multiple engines
|
- Text-To-Speech for multiple engines
|
||||||
- A good API (subjective :P)
|
- A good API (subjective :P)
|
||||||
- All the stuff you expect from a translation utility :)
|
- All the stuff you expect from a translation utility :)
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"codeberg.org/aryak/mozhi/utils"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var file string
|
|
||||||
|
|
||||||
var imgtxtCmd = &cobra.Command{
|
|
||||||
Use: "imgtxt",
|
|
||||||
Short: "Image -> Text.",
|
|
||||||
Long: `Convert given image (filename) to text using gosseract.`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
text, err := utils.ImgTxt(file)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Failed to convert image to text: ", err)
|
|
||||||
} else {
|
|
||||||
fmt.Println(text)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
rootCmd.AddCommand(imgtxtCmd)
|
|
||||||
|
|
||||||
imgtxtCmd.Flags().StringVarP(&file, "file", "f", "", "The query Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_query environment variable.")
|
|
||||||
|
|
||||||
langlist = imgtxtCmd.Flag("file").Value.String()
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/otiai10/gosseract/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ImgTxt(file string) (string, error) {
|
|
||||||
client := gosseract.NewClient()
|
|
||||||
defer client.Close()
|
|
||||||
client.SetImage(file)
|
|
||||||
text, err := client.Text()
|
|
||||||
return text, err
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user